Documentation ¶
Index ¶
- Constants
- func GetColVector(matrix mat.Dense, index int) mat.VecDense
- func GetMaxIndex(vector mat.VecDense) int
- func Mae(yTrue, yPred mat.VecDense) (float64, error)
- func MaeDerivative(yTrue, yPred mat.VecDense) (mat.VecDense, error)
- func Mse(yTrue, yPred mat.VecDense) (float64, error)
- func MseDerivative(yTrue, yPred mat.VecDense) (mat.VecDense, error)
- func Relu(x float64) float64
- func ReluDerivative(x float64) float64
- func Sigmoid(x float64) float64
- func SigmoidDerivative(x float64) float64
- func Tanh(x float64) float64
- func TanhDerivative(x float64) float64
- type Activation
- type Base
- type Dense
- type Layer
- type Network
- type Set
- type SplitSet
Constants ¶
const ( ActivationSigmoid = 0 ActivationRelu = 1 ActivationTanh = 2 )
Each constant represents an activation function and its derivative This makes the definition of neural networks easier
const ( LossMse = 0 LossMae = 1 )
Each constant represents an loss function and its derivative This makes the definition of neural networks easier
Variables ¶
This section is empty.
Functions ¶
func GetColVector ¶
return the column as a vector instead of an slice
func GetMaxIndex ¶
returns the index of the element with the max value
func ReluDerivative ¶
func SigmoidDerivative ¶
func TanhDerivative ¶
Types ¶
type Activation ¶
type Activation struct {
// contains filtered or unexported fields
}
consists of a base layer and an activation function this layer just applies the activation function to the output of a dense layer
func NewActivation ¶
func NewActivation(size, activationSpecs int) (*Activation, error)
constructor for Activation layer
creates a new activation layer with random values for the input and output with the given data
inputSize and outputSize need to be positive
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
basic layer which consists of input and output vector
type Dense ¶
type Dense struct {
// contains filtered or unexported fields
}
Dense layer consists of a base layer with a weight matrix, bias vector
type Layer ¶
type Layer interface {
// contains filtered or unexported methods
}
default methods that have to be implemented by each layer
a layer needs an forward and backward propagation method
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
specifies a neural network layers are saved inside a slice this structure allows for almost every possible neural network configuration
func NewNetwork ¶
create a neural network each layer is specified by a subslice e.g. {4, 5, 0} specifies a layer with 4 input, 5 output neurons and Sigmoid as a activation function
func (*Network) EvaluateOneHot ¶
this evaluate function only works for one hot encoded input
type Set ¶
saves all the data and labels
the used data consists of float vectors this achieves maximum flexibility users can use one hot encoding, one dimensional vectors and n-dimensional vectors
each index of the data corresponds to the same label index in the labels data labels are saved as vectors for easier access during the training process labels row size should match the output size of the output layer
you can read the complete dataset and then later convert it into splitSet with splitDataSet()
type SplitSet ¶
saves train and test data into struct
func NewSplitSet ¶
converts data vectors into a matrix each subslice of the data slice should represent a vector the size of each label vector should match the output size of the output layer