Documentation ¶
Index ¶
- type Abs
- type Add
- type AddScalar
- type Affine
- type AppendRows
- type At
- type CELU
- type ColView
- type Concat
- type Copy
- type Cos
- type Div
- type DivScalar
- type Dot
- type Dropout
- type ELU
- type Exp
- type Flatten
- type GELU
- type HardSigmoid
- type HardTanh
- type LeakyReLU
- type Log
- type Max
- type MaxPooling
- type Min
- type Mish
- type Mul
- type MulT
- type Neg
- type Pow
- type Prod
- type ProdScalar
- type ReLU
- type Reciprocal
- type ReduceMax
- type ReduceMean
- type ReduceSum
- type Reshape
- type ReverseSubScalar
- type RotateR
- type RowView
- type SELU
- type ScalarMax
- type Sigmoid
- type Sin
- type Slice
- type SoftPlus
- type SoftShrink
- type Softmax
- type Softsign
- type SparseMax
- type SparseMaxLoss
- type Sqrt
- type Square
- type Stack
- type Sub
- type SubScalar
- type Swish
- type SwishB
- type Tan
- type Tanh
- type Threshold
- type Transpose
- type UnaryElementwise
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Abs ¶
type Abs[O mat.Tensor] struct { *UnaryElementwise[O] }
Abs is an operator to perform element-wise absolute value function.
type Add ¶
Add is an operator to perform element-wise sum over two values. y = x1 + x2
type AddScalar ¶
AddScalar is an operator to perform element-wise addition over two values.
func NewAddScalar ¶
NewAddScalar returns a new AddScalar Function.
type Affine ¶
Affine is an operator to apply the affine function y = b + W1x1 + W2x2 + ... + WnXn.
func NewAffine ¶
NewAffine returns a new Affine Function.
The affine transformation is in the form y = b + W1x1 + W2x2 + ... + WnXn. The function accepts the bias "b", the first mandatory pair of "w1" and "x1", and then an optional arbitrary list of (w, x) pairs, that is "w2", "x2", "w3", "x3", ..., "wN", "xN".
For each additional pair (w, x), x is allowed to be nil. In this case, the pair is completely ignored. For example, given the arguments (b, w1, x1, w2, x2, w3, x3), if only x2 is nil, the actual operation performed will be y = b + w1x1 + w3x3.
If no additional (w, x) pair is given, or all x values of wxPairs are nil, the actual function is just y = b + W1x1.
It panics if the length of wxs is not even.
type AppendRows ¶
AppendRows is a Function which appends new tail rows to a matrix.
func NewAppendRows ¶
func NewAppendRows[O mat.Tensor](x O, vs ...O) *AppendRows[O]
NewAppendRows returns a new AppendRows Function.
func (*AppendRows[O]) Backward ¶
func (a *AppendRows[O]) Backward(gy mat.Tensor) error
Backward computes the backward pass.
func (*AppendRows[O]) Forward ¶
func (a *AppendRows[O]) Forward() (mat.Tensor, error)
Forward computes the output of the function.
func (*AppendRows[O]) Operands ¶
func (a *AppendRows[O]) Operands() []O
Operands returns the list of operands.
type At ¶
At is an operator to obtain the i,j-th value of a matrix.
type CELU ¶
CELU is an operator to perform the CELU activation. CELU(x) = max(0,x) + min(0,α ∗ (exp(x/α) − 1))
type ColView ¶
ColView is an operator to extract the i-th column from a matrix.
func NewColView ¶
NewColView extracts the i-th column from the input matrix.
type Concat ¶
Concat is an operator to perform vector concatenation.
type Copy ¶
Copy is an operator to perform copy function. y = x
type Cos ¶
type Cos[O mat.Tensor] struct { *UnaryElementwise[O] }
Cos is an operator to perform element-wise cos.
type Div ¶
Div is an operator to perform element-wise division over two values.
type DivScalar ¶
DivScalar is an operator to perform element-wise division with a scalar value.
func NewDivScalar ¶
NewDivScalar returns a new DivScalar Function.
type Dot ¶
Dot is an operator to perform the dot product over two matrices. y = x1 dot x2
type Dropout ¶
Dropout is an operator to perform elements dropout with a probability.
func NewDropout ¶
NewDropout returns a new Dropout Function.
type ELU ¶
ELU is an operator to perform the ELU activation function. ELU(x) = max(0,x) + min(0,α ∗ (exp(x) − 1))
type Exp ¶
Exp is an operator to perform element-wise base-e exponential function.
type Flatten ¶
Flatten is a Function to reshape a matrix-operand into a "flattened" row vector.
func NewFlatten ¶
NewFlatten returns a new Flatten Function.
type GELU ¶
type GELU[O mat.Tensor] struct { *UnaryElementwise[O] }
GELU is an operator to perform element-wise GELU.
type HardSigmoid ¶
type HardSigmoid[O mat.Tensor] struct { *UnaryElementwise[O] }
HardSigmoid is an operator to perform element-wise hard sigmoid.
func NewHardSigmoid ¶
func NewHardSigmoid[O mat.Tensor](x O) *HardSigmoid[O]
NewHardSigmoid returns a new UnaryElementwise hard sigmoid function.
type HardTanh ¶
type HardTanh[O mat.Tensor] struct { *UnaryElementwise[O] }
HardTanh is an operator to perform element-wise hard hyperbolic tangent.
func NewHardTanh ¶
NewHardTanh returns a new UnaryElementwise hard hyperbolic tangent function.
type LeakyReLU ¶
LeakyReLU is an operator to perform the LeakyReLU activation function. LeakyReLU(x) = max(0,x) + slope ° min(0,x)
func NewLeakyReLU ¶
NewLeakyReLU returns a new LeakyReLU Function.
type Log ¶
Log is an operator to perform element-wise natural logarithm function.
type Max ¶
Max is an operator to perform element-wise max. y = max(x1, x2)
type MaxPooling ¶
MaxPooling is an operator to perform max pooling.
func NewMaxPooling ¶
func NewMaxPooling[O mat.Tensor](x O, r, c int) *MaxPooling[O]
NewMaxPooling returns a new MaxPooling Function.
func (*MaxPooling[O]) Backward ¶
func (r *MaxPooling[O]) Backward(gy mat.Tensor) error
Backward computes the backward pass.
func (*MaxPooling[O]) Forward ¶
func (r *MaxPooling[O]) Forward() (mat.Tensor, error)
Forward computes the output of the function.
func (*MaxPooling[O]) Operands ¶
func (r *MaxPooling[O]) Operands() []mat.Tensor
Operands returns the list of operands.
type Min ¶
Min is an operator to perform element-wise min. y = min(x1, x2)
type Mish ¶
type Mish[O mat.Tensor] struct { *UnaryElementwise[O] }
Mish is an operator to perform element-wise mish.
func NewMish ¶
NewMish returns a new UnaryElementwise Mish function.
Mish is a self-regularized non-monotonic activation function which can be mathematically defined as f(x) = x * tanh(softplus(x)).
Reference: "Mish: A Self Regularized Non-Monotonic Neural Activation Function" by Diganta Misra, 2019 (https://arxiv.org/pdf/1908.08681.pdf)
type Mul ¶
Mul is an operator to perform matrix-vector multiplication.
type MulT ¶
MulT is an operator to perform matrix-vector multiplication.
type Neg ¶
type Neg[O mat.Tensor] struct { *UnaryElementwise[O] }
Neg is an operator to perform element-wise f(x) = -x
type Pow ¶
Pow is an operator to perform element-wise pow function.
type Prod ¶
Prod is an operator to perform element-wise product over two values.
type ProdScalar ¶
ProdScalar is an operator to perform element-wise product with a scalar value.
func NewProdScalar ¶
func NewProdScalar[O mat.Tensor](x1 O, x2 O) *ProdScalar[O]
NewProdScalar returns a new ProdScalar Function.
func (*ProdScalar[O]) Backward ¶
func (r *ProdScalar[O]) Backward(gy mat.Tensor) error
Backward computes the backward pass.
func (*ProdScalar[O]) Forward ¶
func (r *ProdScalar[O]) Forward() (mat.Tensor, error)
Forward computes the output of the node.
func (*ProdScalar[O]) Operands ¶
func (r *ProdScalar[O]) Operands() []mat.Tensor
Operands returns the list of operands.
type ReLU ¶
type ReLU[O mat.Tensor] struct { *UnaryElementwise[O] }
ReLU is an operator to perform element-wise Rectified Linear Unit (ReLU)
type Reciprocal ¶
type Reciprocal[O mat.Tensor] struct { *UnaryElementwise[O] }
Reciprocal is an operator to perform element-wise reciprocal.
func NewReciprocal ¶
func NewReciprocal[O mat.Tensor](x O) *Reciprocal[O]
NewReciprocal returns a new UnaryElementwise reciprocal function.
type ReduceMax ¶
ReduceMax is an operator to perform reduce-max function. It gets the maximum element of the Operand x
func NewReduceMax ¶
NewReduceMax returns a new ReduceMax Function.
type ReduceMean ¶
ReduceMean is an operator to perform reduce-mean function.
func NewReduceMean ¶
func NewReduceMean[O mat.Tensor](x O) *ReduceMean[O]
NewReduceMean returns a new ReduceMean Function.
func (*ReduceMean[O]) Backward ¶
func (r *ReduceMean[O]) Backward(gy mat.Tensor) error
Backward computes the backward pass.
func (*ReduceMean[O]) Forward ¶
func (r *ReduceMean[O]) Forward() (mat.Tensor, error)
Forward computes the output of this node.
func (*ReduceMean[O]) Operands ¶
func (r *ReduceMean[O]) Operands() []mat.Tensor
Operands returns the list of operands.
type ReduceSum ¶
ReduceSum is an operator to perform reduce-sum function.
func NewReduceSum ¶
NewReduceSum returns a new ReduceSum Function.
type Reshape ¶
Reshape is a Function which reshapes an operand into a new matrix of given rows × columns size.
func NewReshape ¶
NewReshape returns a new Reshape Function.
type ReverseSubScalar ¶
ReverseSubScalar is the element-wise subtraction function over two values.
func NewReverseSubScalar ¶
func NewReverseSubScalar[O mat.Tensor](x1 O, x2 O) *ReverseSubScalar[O]
NewReverseSubScalar returns a new ReverseSubScalar Function.
func (*ReverseSubScalar[O]) Backward ¶
func (r *ReverseSubScalar[O]) Backward(gy mat.Tensor) error
Backward computes the backward pass.
func (*ReverseSubScalar[O]) Forward ¶
func (r *ReverseSubScalar[O]) Forward() (mat.Tensor, error)
Forward computes the output of the function.
func (*ReverseSubScalar[O]) Operands ¶
func (r *ReverseSubScalar[O]) Operands() []mat.Tensor
Operands returns the list of operands.
type RotateR ¶
RotateR is a function to perform a right circular shift of a vector.
func NewRotateR ¶
NewRotateR returns a new RotateR Function. `i` is the number of places by which the elements are shifted.
type RowView ¶
RowView is a function to extract the i-th row from the input matrix.
func NewRowView ¶
NewRowView returns a new RowView Function.
type SELU ¶
SELU function: f(x) = scale ∗ (max(0,x) + min(0, α ∗ (exp(x) − 1)))
type ScalarMax ¶
ScalarMax is an operator to perform reduce-max function on a list of scalars. It gets the maximum element of the Operand x
func NewScalarMax ¶
NewScalarMax returns a new ScalarMax Function.
type Sigmoid ¶
Sigmoid is an operator to perform element-wise sigmoid function.
func NewSigmoid ¶
NewSigmoid returns a new Log Function.
type Sin ¶
type Sin[O mat.Tensor] struct { *UnaryElementwise[O] }
Sin is an operator to perform element-wise sin.
type Slice ¶
Slice is a function to extract a portion of a matrix.
type SoftPlus ¶
SoftPlus function: f(x) = 1 / β ∗ log(1 + exp(β ∗ x))
func NewSoftPlus ¶
NewSoftPlus returns a new SoftPlus Function.
type SoftShrink ¶
SoftShrink function: f(x) = x − λ if x > λ; x + λ if x < −λ; 0 otherwise.
func NewSoftShrink ¶
func NewSoftShrink[O mat.Tensor](x O, lambda O) *SoftShrink[O]
NewSoftShrink returns a new SoftShrink Function.
func (*SoftShrink[O]) Backward ¶
func (r *SoftShrink[O]) Backward(gy mat.Tensor) error
Backward computes the backward pass.
func (*SoftShrink[O]) Forward ¶
func (r *SoftShrink[O]) Forward() (mat.Tensor, error)
Forward computes the output of the function.
func (*SoftShrink[O]) Operands ¶
func (r *SoftShrink[O]) Operands() []mat.Tensor
Operands returns the list of operands.
type Softmax ¶
Softmax is a single-input softmax function.
func NewSoftmax ¶
NewSoftmax returns a new Softmax Function.
type Softsign ¶
type Softsign[O mat.Tensor] struct { *UnaryElementwise[O] }
Softsign is an operator to perform element-wise softsign.
func NewSoftsign ¶
NewSoftsign returns a new UnaryElementwise softsign function.
type SparseMax ¶
SparseMax function implementation, based on https://github.com/gokceneraslan/SparseMax.torch
func NewSparseMax ¶
NewSparseMax returns a new SparseMax Function.
type SparseMaxLoss ¶
SparseMaxLoss function implementation, based on https://github.com/gokceneraslan/SparseMax.torch
func NewSparseMaxLoss ¶
func NewSparseMaxLoss[O mat.Tensor](x O) *SparseMaxLoss[O]
NewSparseMaxLoss returns a new SparseMaxLoss Function.
func (*SparseMaxLoss[O]) Backward ¶
func (r *SparseMaxLoss[O]) Backward(gy mat.Tensor) error
Backward computes the backward pass.
func (*SparseMaxLoss[O]) Forward ¶
func (r *SparseMaxLoss[O]) Forward() (mat.Tensor, error)
Forward computes the output of the function.
func (*SparseMaxLoss[O]) Operands ¶
func (r *SparseMaxLoss[O]) Operands() []mat.Tensor
Operands returns the list of operands.
type Sqrt ¶
Sqrt is an operator to perform element-wise square root function.
type Stack ¶
Stack is a Function which stacks together all given operand matrices, producing a single bigger matrix as result.
type Sub ¶
Sub is an element-wise subtraction function over two values.
type SubScalar ¶
SubScalar is an element-wise subtraction function with a scalar value.
func NewSubScalar ¶
NewSubScalar returns a new SubScalar Function.
type Swish ¶
Swish is an operator to perform element-wise swish function: y = x * sigmoid(x).
func NewSiLU ¶
NewSiLU (Sigmoid Linear Unit) returns a new function of the form f(x) = x * sigmoid(x). The function in an alias of NewSwish.
type SwishB ¶
SwishB function: f(x) = x * sigmoid.
Reference: "Searching for Activation Functions" by Ramachandran et al, 2017. (https://arxiv.org/pdf/1710.05941.pdf)
type Tan ¶
type Tan[O mat.Tensor] struct { *UnaryElementwise[O] }
Tan is an operator to perform element-wise tangent.
type Tanh ¶
type Tanh[O mat.Tensor] struct { *UnaryElementwise[O] }
Tanh is an operator to perform element-wise hyperbolic tangent.
type Threshold ¶
Threshold function: f(x) = x if x > threshold; k otherwise.
func NewThreshold ¶
NewThreshold returns a new Threshold Function.
type Transpose ¶
Transpose is a Function to calculate the transpose of the matrix-operand.
func NewTranspose ¶
NewTranspose returns a new Transpose Function.
type UnaryElementwise ¶
UnaryElementwise is a single-input element-wise function.
func (*UnaryElementwise[O]) Backward ¶
func (r *UnaryElementwise[O]) Backward(gy mat.Tensor) error
Backward computes the backward pass.
func (*UnaryElementwise[O]) Forward ¶
func (r *UnaryElementwise[O]) Forward() (mat.Tensor, error)
Forward computes the output of this node.
func (*UnaryElementwise[O]) Operands ¶
func (r *UnaryElementwise[O]) Operands() []mat.Tensor
Operands returns the list of operands.
Source Files ¶
- add.go
- addscalar.go
- affine.go
- appendrows.go
- at.go
- celu.go
- colview.go
- concat.go
- div.go
- divscalar.go
- dot.go
- dropout.go
- elu.go
- exp.go
- flatten.go
- identity.go
- leakyrelu.go
- log.go
- max.go
- maxpooling.go
- min.go
- misc.go
- mul.go
- mult.go
- pow.go
- prod.go
- prodscalar.go
- reducemax.go
- reducemean.go
- reducesum.go
- reshape.go
- reversesubscalar.go
- rotater.go
- rowview.go
- scalarmax.go
- selu.go
- sigmoid.go
- slice.go
- softmax.go
- softplus.go
- softshrink.go
- sparsemax.go
- sparsemax_loss.go
- sqrt.go
- square.go
- stack.go
- sub.go
- subscalar.go
- swish.go
- swishb.go
- threshold.go
- transpose.go
- unaryelementwise.go