fn

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewSiLU = NewSwish

NewSiLU (Sigmoid Linear Unit) returns a new function of the form f(x) = x * sigmoid(x). The function in an alias of NewSwish.

Functions

This section is empty.

Types

type Abs added in v0.6.0

type Abs struct {
	*UnaryElementwise
}

Abs is an operator to perform element-wise absolute value function.

func NewAbs

func NewAbs(x Operand) *Abs

NewAbs returns a new UnaryElementwise absolute value function.

type Add

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

Add is an operator to perform element-wise sum over two values. y = x1 + x2

func NewAdd

func NewAdd(x1, x2 Operand) *Add

NewAdd returns a new Add Function.

func (*Add) Backward

func (r *Add) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Add) Forward

func (r *Add) Forward() mat.Matrix

Forward computes the output of the function.

type AddScalar

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

AddScalar is an operator to perform element-wise addition over two values.

func NewAddScalar

func NewAddScalar(x1, x2 Operand) *AddScalar

NewAddScalar returns a new AddScalar Function.

func (*AddScalar) Backward

func (r *AddScalar) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*AddScalar) Forward

func (r *AddScalar) Forward() mat.Matrix

Forward computes the output of the function. It doesn't backward on the scalar value x2.

type At

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

At is an operator to obtain the i,j-th value of a matrix.

func NewAt

func NewAt(x Operand, i int, j int) *At

NewAt returns a new At Function.

func (*At) Backward

func (r *At) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*At) Forward

func (r *At) Forward() mat.Matrix

Forward computes the output of the function.

type AtVec

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

AtVec is an operator to obtain the i-th value of a vector.

func NewAtVec

func NewAtVec(x Operand, i int) *AtVec

NewAtVec returns a new AtVec Function.

func (*AtVec) Backward

func (r *AtVec) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*AtVec) Forward

func (r *AtVec) Forward() mat.Matrix

Forward computes the output of the function.

type CELU added in v0.2.0

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

CELU is an operator to perform the CELU activation. CELU(x) = max(0,x) + min(0,α ∗ (exp(x/α) − 1))

func NewCELU added in v0.2.0

func NewCELU(x, alpha Operand) *CELU

NewCELU returns a new CELU Function.

func (*CELU) Backward added in v0.2.0

func (r *CELU) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*CELU) Forward added in v0.2.0

func (r *CELU) Forward() mat.Matrix

Forward computes the output of the function.

type ColView

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

ColView is an operator to extract the i-th column from a matrix.

func NewColView

func NewColView(x Operand, i int) *ColView

NewColView extracts the i-th column from the input matrix.

func (*ColView) Backward

func (r *ColView) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*ColView) Forward

func (r *ColView) Forward() mat.Matrix

Forward computes the output of the function.

type Concat

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

Concat is an operator to perform vector concatenation.

func NewConcat

func NewConcat(xs []Operand) *Concat

NewConcat returns a new Concat Function.

func (*Concat) Backward

func (r *Concat) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Concat) Forward

func (r *Concat) Forward() mat.Matrix

Forward computes the output of the function.

type Cos added in v0.6.0

type Cos struct {
	*UnaryElementwise
}

Cos is an operator to perform element-wise cos.

func NewCos

func NewCos(x Operand) *Cos

NewCos returns a new UnaryElementwise cos function.

type Div

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

Div is an operator to perform element-wise division over two values.

func NewDiv

func NewDiv(x1, x2 Operand) *Div

NewDiv returns a new Div Function.

func (*Div) Backward

func (r *Div) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Div) Forward

func (r *Div) Forward() mat.Matrix

Forward computes the output of the function.

type DivScalar

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

DivScalar is an operator to perform element-wise division with a scalar value.

func NewDivScalar

func NewDivScalar(x1, x2 Operand) *DivScalar

NewDivScalar returns a new DivScalar Function.

func (*DivScalar) Backward

func (r *DivScalar) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*DivScalar) Forward

func (r *DivScalar) Forward() mat.Matrix

Forward computes the output of the function.

type Dot

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

Dot is an operator to perform the dot product over two matrices. y = x1 dot x2

func NewDot

func NewDot(x1, x2 Operand) *Dot

NewDot returns a new Dot Function.

func (*Dot) Backward

func (r *Dot) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Dot) Forward

func (r *Dot) Forward() mat.Matrix

Forward computes the output of the function.

type Dropout

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

Dropout is an operator to perform elements dropout with a probability.

func NewDropout

func NewDropout(x Operand, p mat.Float, randGen *rand.LockedRand) *Dropout

NewDropout returns a new Dropout Function.

func (*Dropout) Backward

func (r *Dropout) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Dropout) Forward

func (r *Dropout) Forward() mat.Matrix

Forward computes the output of the function.

type ELU

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

ELU is an operator to perform the ELU activation function. ELU(x) = max(0,x) + min(0,α ∗ (exp(x) − 1))

func NewELU

func NewELU(x, alpha Operand) *ELU

NewELU returns a new ELU Function.

func (*ELU) Backward

func (r *ELU) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*ELU) Forward

func (r *ELU) Forward() mat.Matrix

Forward computes the output of the function.

type Exp added in v0.6.0

type Exp struct {
	*UnaryElementwise
}

Exp is an operator to perform element-wise base-e exponential.

func NewExp

func NewExp(x Operand) *Exp

NewExp returns a new UnaryElementwise base-e exponential function.

type Function

type Function interface {
	// Forward computes the output of the function.
	Forward() mat.Matrix
	// Backward computes the backward pass.
	Backward(gy mat.Matrix)
}

Function represents a function with automatic differentiation features.

type GELU added in v0.6.0

type GELU struct {
	*UnaryElementwise
}

GELU is an operator to perform element-wise GELU.

func NewGELU added in v0.2.0

func NewGELU(x Operand) *GELU

NewGELU returns a new UnaryElementwise Gaussian Error Linear Unit (GELU) function.

type HardSigmoid added in v0.6.0

type HardSigmoid struct {
	*UnaryElementwise
}

HardSigmoid is an operator to perform element-wise hard sigmoid.

func NewHardSigmoid

func NewHardSigmoid(x Operand) *HardSigmoid

NewHardSigmoid returns a new UnaryElementwise hard sigmoid function.

type HardTanh added in v0.6.0

type HardTanh struct {
	*UnaryElementwise
}

HardTanh is an operator to perform element-wise hard hyperbolic tangent.

func NewHardTanh

func NewHardTanh(x Operand) *HardTanh

NewHardTanh returns a new UnaryElementwise hard hyperbolic tangent function.

type Identity

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

Identity is an operator to perform identity function. y = x

func NewIdentity

func NewIdentity(x Operand) *Identity

NewIdentity returns a new Identity Function.

func (*Identity) Backward

func (r *Identity) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Identity) Forward

func (r *Identity) Forward() mat.Matrix

Forward computes the output of the function.

type LeakyReLU

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

LeakyReLU is an operator to perform the LeakyReLU activation function. LeakyReLU(x) = max(0,x) + slope ° min(0,x)

func NewLeakyReLU

func NewLeakyReLU(x, alpha Operand) *LeakyReLU

NewLeakyReLU returns a new LeakyReLU Function.

func (*LeakyReLU) Backward

func (r *LeakyReLU) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*LeakyReLU) Forward

func (r *LeakyReLU) Forward() mat.Matrix

Forward computes the output of the function.

type Log added in v0.6.0

type Log struct {
	*UnaryElementwise
}

Log is an operator to perform element-wise natural logarithm.

func NewLog

func NewLog(x Operand) *Log

NewLog returns a new UnaryElementwise natural logarithm function.

type Max

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

Max is an operator to perform element-wise max. y = max(x1, x2)

func NewMax

func NewMax(x1, x2 Operand) *Max

NewMax returns a new Max Function.

func (*Max) Backward

func (r *Max) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Max) Forward

func (r *Max) Forward() mat.Matrix

Forward computes the output of the function.

type MaxPooling

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

MaxPooling is an operator to perform max pooling.

func NewMaxPooling

func NewMaxPooling(x Operand, r, c int) *MaxPooling

NewMaxPooling returns a new MaxPooling Function.

func (*MaxPooling) Backward

func (r *MaxPooling) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*MaxPooling) Forward

func (r *MaxPooling) Forward() mat.Matrix

Forward computes the output of the function.

type Min

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

Min is an operator to perform element-wise min. y = min(x1, x2)

func NewMin

func NewMin(x1, x2 Operand) *Min

NewMin returns a new Min Function.

func (*Min) Backward

func (r *Min) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Min) Forward

func (r *Min) Forward() mat.Matrix

Forward computes the output of the function.

type Mish added in v0.6.0

type Mish struct {
	*UnaryElementwise
}

Mish is an operator to perform element-wise mish.

func NewMish

func NewMish(x Operand) *Mish

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

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

Mul is an operator to perform matrix-vector multiplication.

func NewMul

func NewMul(x1, x2 Operand) *Mul

NewMul returns a new Mul Function.

func (*Mul) Backward

func (r *Mul) Backward(gy mat.Matrix)

Backward computes the backward pass. TODO: backward of sparse gradients

func (*Mul) Forward

func (r *Mul) Forward() mat.Matrix

Forward computes the output of the function.

type Neg added in v0.6.0

type Neg struct {
	*UnaryElementwise
}

Neg is an operator to perform element-wise f(x) = -x

func NewNeg

func NewNeg(x Operand) *Neg

NewNeg returns a new UnaryElementwise f(x) = -x function.

type Operand

type Operand interface {
	// Value returns the value of the operand.
	Value() mat.Matrix
	// PropagateGrad propagates the gradients gx to the operands.
	PropagateGrad(gx mat.Matrix)
	// RequiresGrad returns true if the operand requires gradients.
	RequiresGrad() bool
}

Operand is implemented by any value that implements automatic differentiation features.

type Pow

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

Pow is an operator to perform element-wise pow function.

func NewPow

func NewPow(x Operand, power mat.Float) *Pow

NewPow returns a new Pow Function.

func (*Pow) Backward

func (r *Pow) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Pow) Forward

func (r *Pow) Forward() mat.Matrix

Forward computes the output of the function.

type Prod

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

Prod is an operator to perform element-wise product over two values.

func NewProd

func NewProd(x1, x2 Operand) *Prod

NewProd returns a new Prod Function.

func (*Prod) Backward

func (r *Prod) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Prod) Forward

func (r *Prod) Forward() mat.Matrix

Forward computes the output of the node.

type ProdScalar

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

ProdScalar is an operator to perform element-wise product with a scalar value.

func NewProdScalar

func NewProdScalar(x1, x2 Operand) *ProdScalar

NewProdScalar returns a new ProdScalar Function.

func (*ProdScalar) Backward

func (r *ProdScalar) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*ProdScalar) Forward

func (r *ProdScalar) Forward() mat.Matrix

Forward computes the output of the node.

type ReLU added in v0.6.0

type ReLU struct {
	*UnaryElementwise
}

ReLU is an operator to perform element-wise Rectified Linear Unit (ReLU)

func NewReLU

func NewReLU(x Operand) *ReLU

NewReLU returns a new UnaryElementwise Rectified Linear Unit (ReLU) function.

type Reciprocal added in v0.6.0

type Reciprocal struct {
	*UnaryElementwise
}

Reciprocal is an operator to perform element-wise reciprocal.

func NewReciprocal

func NewReciprocal(x Operand) *Reciprocal

NewReciprocal returns a new UnaryElementwise reciprocal function.

type ReduceMean

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

ReduceMean is an operator to perform reduce-mean function.

func NewReduceMean

func NewReduceMean(x Operand) *ReduceMean

NewReduceMean returns a new ReduceMean Function.

func (*ReduceMean) Backward

func (r *ReduceMean) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*ReduceMean) Forward

func (r *ReduceMean) Forward() mat.Matrix

Forward computes the output of this node.

type ReduceSum

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

ReduceSum is an operator to perform reduce-sum function.

func NewReduceSum

func NewReduceSum(x Operand) *ReduceSum

NewReduceSum returns a new ReduceSum Function.

func (*ReduceSum) Backward

func (r *ReduceSum) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*ReduceSum) Forward

func (r *ReduceSum) Forward() mat.Matrix

Forward computes the output of this function.

type Reshape

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

Reshape is a Function which reshapes an operand into a new matrix of given rows × columns size.

func NewReshape

func NewReshape(x Operand, r, c int) *Reshape

NewReshape returns a new Reshape Function.

func (*Reshape) Backward

func (r *Reshape) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Reshape) Forward

func (r *Reshape) Forward() mat.Matrix

Forward computes the output of the node.

type ReverseSubScalar

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

ReverseSubScalar is the element-wise subtraction function over two values.

func NewReverseSubScalar

func NewReverseSubScalar(x1, x2 Operand) *ReverseSubScalar

NewReverseSubScalar returns a new ReverseSubScalar Function.

func (*ReverseSubScalar) Backward

func (r *ReverseSubScalar) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*ReverseSubScalar) Forward

func (r *ReverseSubScalar) Forward() mat.Matrix

Forward computes the output of the function.

type RotateR added in v0.2.0

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

RotateR is a function to perform a right circular shift of a vector.

func NewRotateR added in v0.2.0

func NewRotateR(x Operand, i int) *RotateR

NewRotateR returns a new RotateR Function. `i` is the number of places by which the elements are shifted.

func (*RotateR) Backward added in v0.2.0

func (r *RotateR) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*RotateR) Forward added in v0.2.0

func (r *RotateR) Forward() mat.Matrix

Forward computes the output of the function.

type RowView

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

RowView is a function to extract the i-th row from the input matrix.

func NewRowView

func NewRowView(x Operand, i int) *RowView

NewRowView returns a new RowView Function.

func (*RowView) Backward

func (r *RowView) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*RowView) Forward

func (r *RowView) Forward() mat.Matrix

Forward computes the output of the function.

type SELU added in v0.2.0

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

SELU function: f(x) = scale ∗ (max(0,x) + min(0, α ∗ (exp(x) − 1)))

func NewSELU added in v0.2.0

func NewSELU(x, alpha, scale Operand) *SELU

NewSELU returns a new SELU Function.

func (*SELU) Backward added in v0.2.0

func (r *SELU) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*SELU) Forward added in v0.2.0

func (r *SELU) Forward() mat.Matrix

Forward computes the output of the function.

type Sigmoid added in v0.6.0

type Sigmoid struct {
	*UnaryElementwise
}

Sigmoid is an operator to perform element-wise sigmoid.

func NewSigmoid

func NewSigmoid(x Operand) *Sigmoid

NewSigmoid returns a new UnaryElementwise sigmoid function.

type Sin added in v0.6.0

type Sin struct {
	*UnaryElementwise
}

Sin is an operator to perform element-wise sin.

func NewSin

func NewSin(x Operand) *Sin

NewSin returns a new UnaryElementwise sine function.

type SoftPlus

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

SoftPlus function: f(x) = 1 / β ∗ log(1 + exp(β ∗ x))

func NewSoftPlus

func NewSoftPlus(x, beta, threshold Operand) *SoftPlus

NewSoftPlus returns a new SoftPlus Function.

func (*SoftPlus) Backward

func (r *SoftPlus) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*SoftPlus) Forward

func (r *SoftPlus) Forward() mat.Matrix

Forward computes the output of the function.

type SoftShrink

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

SoftShrink function: f(x) = x − λ if x > λ; x + λ if x < −λ; 0 otherwise.

func NewSoftShrink

func NewSoftShrink(x, lambda Operand) *SoftShrink

NewSoftShrink returns a new SoftShrink Function.

func (*SoftShrink) Backward

func (r *SoftShrink) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*SoftShrink) Forward

func (r *SoftShrink) Forward() mat.Matrix

Forward computes the output of the function.

type Softmax

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

Softmax is a single-input softmax function.

func NewSoftmax

func NewSoftmax(x Operand) *Softmax

NewSoftmax returns a new Softmax Function.

func (*Softmax) Backward

func (r *Softmax) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Softmax) Forward

func (r *Softmax) Forward() mat.Matrix

Forward computes the output of this function.

type Softsign added in v0.6.0

type Softsign struct {
	*UnaryElementwise
}

Softsign is an operator to perform element-wise softsign.

func NewSoftsign

func NewSoftsign(x Operand) *Softsign

NewSoftsign returns a new UnaryElementwise softsign function.

type SparseMax

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

SparseMax function implementation, based on https://github.com/gokceneraslan/SparseMax.torch

func NewSparseMax

func NewSparseMax(x Operand) *SparseMax

NewSparseMax returns a new SparseMax Function.

func (*SparseMax) Backward

func (s *SparseMax) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*SparseMax) Forward

func (s *SparseMax) Forward() mat.Matrix

Forward computes the output of the function.

type SparseMaxLoss

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

SparseMaxLoss function implementation, based on https://github.com/gokceneraslan/SparseMax.torch

func NewSparseMaxLoss

func NewSparseMaxLoss(x Operand) *SparseMaxLoss

NewSparseMaxLoss returns a new SparseMaxLoss Function.

func (*SparseMaxLoss) Backward

func (s *SparseMaxLoss) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*SparseMaxLoss) Forward

func (s *SparseMaxLoss) Forward() mat.Matrix

Forward computes the output of the function.

type Sqrt added in v0.6.0

type Sqrt struct {
	*UnaryElementwise
}

Sqrt is an operator to perform element-wise square root.

func NewSqrt

func NewSqrt(x Operand) *Sqrt

NewSqrt returns a new UnaryElementwise square root function.

type Square added in v0.6.0

type Square struct {
	*Prod
}

Square is an operator to perform element-wise square.

func NewSquare

func NewSquare(x Operand) *Square

NewSquare returns a new Prod Function with both operands set to the given value x.

type Stack

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

Stack is a Function which stacks together all given operand matrices, producing a single bigger matrix as result.

func NewStack

func NewStack(xs []Operand) *Stack

NewStack returns a new Stack Function.

func (*Stack) Backward

func (r *Stack) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Stack) Forward

func (r *Stack) Forward() mat.Matrix

Forward computes the output of the function.

type Sub

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

Sub is an element-wise subtraction function over two values.

func NewSub

func NewSub(x1, x2 Operand) *Sub

NewSub returns a new Sub Function.

func (*Sub) Backward

func (r *Sub) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Sub) Forward

func (r *Sub) Forward() mat.Matrix

Forward computes the output of the node.

type SubScalar

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

SubScalar is an element-wise subtraction function with a scalar value.

func NewSubScalar

func NewSubScalar(x1, x2 Operand) *SubScalar

NewSubScalar returns a new SubScalar Function.

func (*SubScalar) Backward

func (r *SubScalar) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*SubScalar) Forward

func (r *SubScalar) Forward() mat.Matrix

Forward computes the output of the node.

type Swish

type Swish struct {
	*UnaryElementwise
}

Swish is an operator to perform element-wise x * sigmoid(x).

func NewSwish

func NewSwish(x Operand) *Swish

NewSwish returns a new function of the form f(x) = x * sigmoid(x).

type SwishB added in v0.5.0

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

SwishB function: f(x) = x * sigmoid.

Reference: "Searching for Activation Functions" by Ramachandran et al, 2017. (https://arxiv.org/pdf/1710.05941.pdf)

func NewSwishB added in v0.5.0

func NewSwishB(x, beta Operand) *SwishB

NewSwishB returns a new SwishB Function.

func (*SwishB) Backward added in v0.5.0

func (r *SwishB) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*SwishB) Forward added in v0.5.0

func (r *SwishB) Forward() mat.Matrix

Forward computes the output of the function.

type Tan added in v0.6.0

type Tan struct {
	*UnaryElementwise
}

Tan is an operator to perform element-wise tangent.

func NewTan

func NewTan(x Operand) *Tan

NewTan returns a new UnaryElementwise tangent function.

type Tanh added in v0.6.0

type Tanh struct {
	*UnaryElementwise
}

Tanh is an operator to perform element-wise hyperbolic tangent.

func NewTanh

func NewTanh(x Operand) *Tanh

NewTanh returns a new UnaryElementwise hyperbolic tangent function.

type Threshold

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

Threshold function: f(x) = x if x > threshold; k otherwise.

func NewThreshold

func NewThreshold(x, threshold, k Operand) *Threshold

NewThreshold returns a new Threshold Function.

func (*Threshold) Backward

func (r *Threshold) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Threshold) Forward

func (r *Threshold) Forward() mat.Matrix

Forward computes the output of the function.

type Transpose

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

Transpose is a Function to calculate the transpose of the matrix-operand.

func NewTranspose

func NewTranspose(x Operand) *Transpose

NewTranspose returns a new Transpose Function.

func (*Transpose) Backward

func (r *Transpose) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Transpose) Forward

func (r *Transpose) Forward() mat.Matrix

Forward computes the output of the node.

type UnaryElementwise

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

UnaryElementwise is a single-input element-wise function.

func (*UnaryElementwise) Backward

func (r *UnaryElementwise) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*UnaryElementwise) Forward

func (r *UnaryElementwise) Forward() mat.Matrix

Forward computes the output of this node.

type Vec

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

Vec is a Function to reshape an matrix-operand into a column vector.

func NewVec

func NewVec(x Operand) *Vec

NewVec returns a new Vec Function.

func (*Vec) Backward

func (r *Vec) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*Vec) Forward

func (r *Vec) Forward() mat.Matrix

Forward computes the output of the node.

type View

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

View is a function to extract a portion of a matrix.

func NewView

func NewView(x Operand, sx, sy, lx, ly int) *View

NewView returns a new View Function.

func (*View) Backward

func (r *View) Backward(gy mat.Matrix)

Backward computes the backward pass.

func (*View) Forward

func (r *View) Forward() mat.Matrix

Forward computes the output of the function.

Jump to

Keyboard shortcuts

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