util

package
v0.1.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WeightName = "model.gt"
	ConfigName = "config.json"

	S3BucketPrefix          = "https://s3.amazonaws.com/models.huggingface.co/bert"
	CloudfrontDistribPrefix = "https://cdn.huggingface.co"
)

Variables

View Source
var (
	DefaultCachePath           string
	PytorchPretrainedBertCache string
	PytorchTransformersCache   string
	TransformersCache          string
)
View Source
var ActivationFnMap map[string]ActivationFn = map[string]ActivationFn{
	"gelu":  NewGelu(),
	"relu":  NewRelu(),
	"tanh":  NewTanh(),
	"swish": NewSwish(),
	"mish":  NewMish(),
}

Functions

func CachedPath

func CachedPath(urlOrFilename string) (resolvedPath string, err error)

CachedPath resolves and caches data based on input string, then returns fullpath to the cached data.

Parameters: - `urlOrFilename`: can be either `URL` to remote file or fullpath a local file.

CachedPath does several things consequently: 1. Resolves input string to a fullpath cached filename candidate. 2. Check it at `CachePath`, if exists, then return the candidate. If not 3. Retrieves and Caches data to `CachePath` and returns path to cached data

Types

type ActivationFn

type ActivationFn interface {
	// Fwd is a forward pass through x.
	Fwd(x *ts.Tensor) *ts.Tensor
	Name() string
}

ActivationFn is an activation function.

type Dropout

type Dropout struct {
	// contains filtered or unexported fields
}

func NewDropout

func NewDropout(p float64) *Dropout

func (*Dropout) ForwardT

func (d *Dropout) ForwardT(input *ts.Tensor, train bool) (retVal *ts.Tensor)

type GeluActivation

type GeluActivation struct {
	// contains filtered or unexported fields
}

func NewGelu

func NewGelu() GeluActivation

func (GeluActivation) Fwd

func (g GeluActivation) Fwd(x *ts.Tensor) (retVal *ts.Tensor)

func (GeluActivation) Name

func (g GeluActivation) Name() (retVal string)

type LinearNoBias

type LinearNoBias struct {
	Ws *ts.Tensor
}

func NewLinearNoBias

func NewLinearNoBias(vs *nn.Path, inDim, outDim int64, config *LinearNoBiasConfig) *LinearNoBias

func (*LinearNoBias) Forward

func (lnb *LinearNoBias) Forward(xs *ts.Tensor) (retVal *ts.Tensor)

Forward implements Module interface for LinearNoBias

type LinearNoBiasConfig

type LinearNoBiasConfig struct {
	WsInit nn.Init // interface
}

func DefaultLinearNoBiasConfig

func DefaultLinearNoBiasConfig() *LinearNoBiasConfig

type MishActivation

type MishActivation struct {
	// contains filtered or unexported fields
}

func NewMish

func NewMish() MishActivation

func (MishActivation) Fwd

func (m MishActivation) Fwd(x *ts.Tensor) (retVal *ts.Tensor)

func (MishActivation) Name

func (m MishActivation) Name() (retVal string)

type ReluActivation

type ReluActivation struct {
	// contains filtered or unexported fields
}

func NewRelu

func NewRelu() ReluActivation

func (ReluActivation) Fwd

func (r ReluActivation) Fwd(x *ts.Tensor) (retVal *ts.Tensor)

func (ReluActivation) Name

func (r ReluActivation) Name() (retVal string)

type SwishActivation

type SwishActivation struct {
	// contains filtered or unexported fields
}

func NewSwish

func NewSwish() SwishActivation

func (SwishActivation) Fwd

func (s SwishActivation) Fwd(x *ts.Tensor) (retVal *ts.Tensor)

func (SwishActivation) Name

func (s SwishActivation) Name() (retVal string)

type TanhActivation

type TanhActivation struct {
	// contains filtered or unexported fields
}

func NewTanh

func NewTanh() TanhActivation

func (TanhActivation) Fwd

func (t TanhActivation) Fwd(x *ts.Tensor) (retVal *ts.Tensor)

func (TanhActivation) Name

func (t TanhActivation) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL