Documentation ¶
Index ¶
- Variables
- func Apply(m Model, fn func(model Model))
- func Dump(obj any, w io.Writer) error
- func DumpToFile[T any](obj T, filename string) error
- func ForEachParam(m Model, fn func(param *Param))
- func ForEachParamStrict(m Model, fn func(param *Param))
- func Load[T any](r io.Reader) (T, error)
- func LoadFromFile[T any](filename string) (T, error)
- func ZeroGrad(m Model)
- type Buffer
- type Model
- type Module
- type ModuleList
- type Param
- type ParamChannelFunc
- type ParamsTraverser
- type StandardModel
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidIndex = errors.New("nn: invalid index")
Functions ¶
func Apply ¶
Apply fn recursively to every sub-models as well as self. Typical use includes initializing the parameters of a model.
func Dump ¶
Dump saves a serialized object to a stream. This function uses Gob utility for serialization. Models, matrices, and all kinds of Gob serializable objects can be saved using this function.
func DumpToFile ¶
DumpToFile saves a serialized object to a file. See Dump for further details.
func ForEachParam ¶
ForEachParam iterate all the parameters of a model also exploring the sub-parameters recursively.
func ForEachParamStrict ¶
ForEachParamStrict iterate all the parameters of a model without exploring the sub-models.
func LoadFromFile ¶
LoadFromFile uses Gob to deserialize objects files to memory. See Load for further details.
Types ¶
type Buffer ¶
Buffer is a type of Node that do not require gradients but that can be serialized similarly to any other parameters. This is useful e.g. to store constants, to track the mean and std in batch norm layers etc.
type Model ¶
type Model interface {
// contains filtered or unexported methods
}
Model is implemented by all neural network architectures.
type ModuleList ¶ added in v1.1.0
type ModuleList[T StandardModel] []T
type Param ¶
type Param struct { mat.Matrix State interface{} // support structure for the optimization algorithm }
func (*Param) ReplaceValue ¶
type ParamChannelFunc ¶ added in v1.1.0
func Parameters ¶ added in v1.1.0
func Parameters(m Model) ParamChannelFunc
func StreamParams ¶ added in v1.1.0
func StreamParams(params []*Param) ParamChannelFunc
type ParamsTraverser ¶
type ParamsTraverser interface { // TraverseParams visit each Param. TraverseParams(callback func(param *Param)) }
ParamsTraverser allows you to define a custom procedure to traverse the parameters of a model. If a model implements this procedure, it will take precedence over the regular parameters visit.
type StandardModel ¶
type StandardModel interface { Model // Forward executes the forward step of the model. Forward(...mat.Tensor) []mat.Tensor }
StandardModel consists of a model that implements a Forward variadic function that accepts mat.Tensor and returns a slice of mat.Tensor. It is called StandardModel since this is the most frequent forward method among all implemented neural models.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
approxlinear
module
|
|
conv1x1
Package conv1x1 implements a 1-dimensional 1-kernel convolution model
|
Package conv1x1 implements a 1-dimensional 1-kernel convolution model |
Package gmlp implements a model composed by basic MLP layers with gating mechanism.
|
Package gmlp implements a model composed by basic MLP layers with gating mechanism. |
gnn
|
|
slstm
Package slstm implements a Sentence-State LSTM graph neural network.
|
Package slstm implements a Sentence-State LSTM graph neural network. |
Package mlpmixer implements the MLP-Mixer (Tolstikhin et al., 2021).
|
Package mlpmixer implements the MLP-Mixer (Tolstikhin et al., 2021). |
normalization
|
|
adanorm
Package adanorm implements the Adaptive Normalization (AdaNorm) method.
|
Package adanorm implements the Adaptive Normalization (AdaNorm) method. |
fixnorm
Package fixnorm implements the fixnorm normalization method.
|
Package fixnorm implements the fixnorm normalization method. |
layernorm
Package layernorm implements the Layer Normalization (LayerNorm) i method.
|
Package layernorm implements the Layer Normalization (LayerNorm) i method. |
layernormsimple
Package layernormsimple implements a simple version of LayerNorm (LayerNorm-simple).
|
Package layernormsimple implements a simple version of LayerNorm (LayerNorm-simple). |
rmsnorm
Package rmsnorm implements the Root Mean Square Layer Normalization method.
|
Package rmsnorm implements the Root Mean Square Layer Normalization method. |
recurrent
|
|
Package sgu implements the Spatial Gating Unit (SGU).
|
Package sgu implements the Spatial Gating Unit (SGU). |