Documentation
¶
Index ¶
- Constants
- func ApplyDropoutMask(a *mat.Dense, mask []bool, p float64)
- func BinaryCrossEntropy(y_hat, y *mat.Dense, parameters map[string]*mat.Dense, lambd float64) float64
- func CrossEntropy(y_hat, y *mat.Dense, parameters map[string]*mat.Dense, lambd float64) float64
- func DropoutMask(a *mat.Dense, p float64) []bool
- func Elu(a *mat.Dense) *mat.Dense
- func EluDerivative(a *mat.Dense) *mat.Dense
- func Linear(a *mat.Dense) *mat.Dense
- func MeanSquaredError(yHat, y *mat.Dense, parameters map[string]*mat.Dense, lambd float64) float64
- func ReLU(a *mat.Dense) *mat.Dense
- func ReLUDerivative(a *mat.Dense) *mat.Dense
- func Sigmoid(a *mat.Dense) *mat.Dense
- func SigmoidDerivative(a *mat.Dense) *mat.Dense
- func SigmoidScalar(x float64) float64
- func Softmax(a *mat.Dense) *mat.Dense
- func Tanh(a *mat.Dense) *mat.Dense
- func TanhDerivative(a *mat.Dense) *mat.Dense
- type Activation
- type ActivationFunction
- type ActivationType
- type Dense
- func (dn *Dense) BackwardPropagation(Z, A map[string]*mat.Dense, D map[string][]bool, y *mat.Dense) (*mat.Dense, map[string]*mat.Dense, map[string]*mat.Dense)
- func (dn *Dense) ForwardPropagation(x *mat.Dense, training bool) (*mat.Dense, map[string]*mat.Dense, map[string]*mat.Dense, map[string][]bool)
- func (dn *Dense) MarshalParameters() ([]byte, error)
- func (dn *Dense) TrainableParameters(dW, db map[string]*mat.Dense) []*Parameter
- func (dn *Dense) UnmarshalParameters(data []byte) error
- func (dn *Dense) UpdateParameters(dW, db map[string]*mat.Dense, learningRate float64)
- type DenseConfig
- type LossFunction
- type Mode
- type ModeType
- type Optimizer
- type OptimizerType
- type OutputActivation
- type OutputActivationFunction
- type Parameter
Constants ¶
const ( TanhActivation ActivationType = "tanh" SigmoidActivation ActivationType = "sigmoid" EluActivation ActivationType = "elu" ReLUActivation ActivationType = "relu" ModeRegression ModeType = "regression" // linear output with mse loss ModeMultiClass ModeType = "multiclass" // softmax output with cross entropy loss ModeMultiLabel ModeType = "multilabel" // sigmoid output with binary cross entropy loss )
Variables ¶
This section is empty.
Functions ¶
func ApplyDropoutMask ¶
inverted dropout: during training, surviving activations are scaled by 1/(1-p) so that no scaling is required during inference.
func BinaryCrossEntropy ¶
func BinaryCrossEntropy(y_hat, y *mat.Dense, parameters map[string]*mat.Dense, lambd float64) float64
computing the binary cross entropy loss function
func CrossEntropy ¶
computing the cross entropy loss function
func DropoutMask ¶
creates a binary mask for inverted dropout. each element has probability (1-p) of being kept.
func EluDerivative ¶
implements the derivative of the elu function for backpropagation.
func MeanSquaredError ¶
computing the mean squared error loss function
func ReLUDerivative ¶
implements the derivative of the relu function for backpropagation.
func SigmoidDerivative ¶
implements the derivative of the sigmoid function for backpropagation.
func SigmoidScalar ¶
implements the sigmoid function for use in activation functions.
Types ¶
type Activation ¶
type Activation struct {
Name ActivationType
Function ActivationFunction
Derivative ActivationFunction
}
func NewActivation ¶
func NewActivation(actType ActivationType) Activation
type ActivationType ¶
type ActivationType string
type Dense ¶
type Dense struct {
Activation Activation
OutputActivation OutputActivation
Optimizer Optimizer
Parameters map[string]*mat.Dense
Iter float64
L2Regularization float64
Dropout float64
}
func NewDense ¶
func NewDense(config DenseConfig) *Dense
func (*Dense) BackwardPropagation ¶
func (dn *Dense) BackwardPropagation(Z, A map[string]*mat.Dense, D map[string][]bool, y *mat.Dense) (*mat.Dense, map[string]*mat.Dense, map[string]*mat.Dense)
backward propagation step
func (*Dense) ForwardPropagation ¶
func (dn *Dense) ForwardPropagation(x *mat.Dense, training bool) (*mat.Dense, map[string]*mat.Dense, map[string]*mat.Dense, map[string][]bool)
forward propagation step
func (*Dense) MarshalParameters ¶
func (*Dense) TrainableParameters ¶
func (*Dense) UnmarshalParameters ¶
type DenseConfig ¶
type DenseConfig struct {
NNStructure []int
Activation Activation
OutputActivation OutputActivation
Optimizer OptimizerType
}
type LossFunction ¶
type Mode ¶
type Mode struct {
OutputActivation OutputActivation
LossFunction LossFunction
}
type Optimizer ¶
type Optimizer interface {
Name() OptimizerType
Step(parameters []*Parameter, learningRate, t float64)
MarshalState() ([]byte, error)
UnmarshalState([]byte) error
}
func NewOptimizer ¶
func NewOptimizer(optType OptimizerType) Optimizer
type OptimizerType ¶
type OptimizerType string
const ( AdamOptimizer OptimizerType = "adam" GradientDescentOptimizer OptimizerType = "gradientdescent" )
type OutputActivation ¶
type OutputActivation struct {
Mode ModeType
Function OutputActivationFunction
}