Documentation ¶
Overview ¶
Package neuralnetwork implements the machine learning library similar to keras architecture.
Index ¶
- func CrossEntropy(prediction, truth []float64) float64
- func Elu(x float64) float64
- func F1Score(predicted, actual []float64) int
- func FalseNegatives(predicted, actual []float64) int
- func FalsePositives(predicted, actual []float64) int
- func HeUniform(x float64) float64
- func JaccardIndex(predicted, actual []float64) int
- func LassoRegression(actual, pred []float64, lambda float64) float64
- func Mse(prediction, truth []float64) float64
- func OnesInitializer(x float64) float64
- func Precision(predicted, actual []float64) int
- func Recall(predicted, actual []float64) int
- func Relu(x float64) float64
- func RidgeRegression(actual, pred []float64, lambda float64) float64
- func Rmse(prediction, truth []float64) float64
- func Sensitivity(predicted, actual []float64) int
- func Sigmoid(x float64) float64
- func SigmoidPrime(x float64) float64
- func SoftDiceLoss(values []float64, truth []float64) float64
- func Specificity(predicted, actual []float64) int
- func Swish(x float64) float64
- func Tanh(x float64) float64
- func TrueNegatives(predicted, actual []float64) int
- func TruePositivies(predicted, actual []float64) int
- func Variance(fls []float64) float64
- func ZeroInitializer(x float64) float64
- type BatchNormLayer
- type Biases
- type CSVLoader
- type Callback
- type CallbackHistory
- type DenseLayer
- func (d DenseLayer) Call() []float64
- func (d DenseLayer) GetBiases() matrix.Vector
- func (d DenseLayer) GetWeights() matrix.Matrix
- func (d DenseLayer) Name() string
- func (d *DenseLayer) SetBiases(bs matrix.Vector)
- func (d *DenseLayer) SetWeights(kernels matrix.Matrix)
- func (d DenseLayer) TrainableParameters() int
- type DropoutLayer
- type EarlyStopper
- type FlattenLayer
- type InputLayer
- type JSONLoader
- type Layer
- type Loader
- type Metrics
- type Model
- func (m *Model) Add(layer Layer) *Model
- func (m *Model) CallbackList() []Callback
- func (m *Model) Compile(optimizer Optimizer, loss func([]float64, []float64) float64, ms []Metrics)
- func (m *Model) CsvLogger(filename string) error
- func (m *Model) EarlyStopping(index int, patience int, at int, minDdelta float64, mode string)
- func (m *Model) GetLayerByIndex(index int) Layer
- func (m *Model) GetLayerByName(name string) Layer
- func (m *Model) GetMetricsByIndex(index int) Metrics
- func (m *Model) History(filepath string) (*CallbackHistory, error)
- func (m *Model) LearningRateScheduler(fn func(x float64) float64)
- func (m *Model) ModelCheckpoint(filepath string, metrics Metrics, saveWeightsOnly bool) error
- func (m *Model) Predict(values []float64) []float64
- func (m *Model) Summary()
- func (m *Model) Train(trainX, trainY []float64, epochs int) map[string]float64
- type Network
- type Optimizer
- type ReduceLearningRateOnPlateau
- type SoftmaxLayer
- type TrainingLog
- type Weights
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CrossEntropy ¶
CrossEntropy returns the cross entropy loss
func FalseNegatives ¶
FalseNegatives returns the number of false negative predicted values.
func FalsePositives ¶
FalsePositives returns the number of false positive predicted values.
func HeUniform ¶
HeUniform stands for He Initialization or the glorot_unifom for kernel_initialization.
func JaccardIndex ¶
JaccardIndex returns the Jaccard index.
func LassoRegression ¶
LassoRegression returns the LassoRegression or the l1 regularization to the loss function.
func OnesInitializer ¶
OnesInitializer returns the ones initializer for the bias initialization
func RidgeRegression ¶
RidgeRegression returns the RidgeRegression or the l2 regularization to the loss function.
func Sensitivity ¶
Sensitivity returns the sensitivity
func SigmoidPrime ¶
SigmoidPrime is the derivative of the Sigmoid
func SoftDiceLoss ¶
SoftDiceLoss implements the soft dice loss.
func Specificity ¶
Specificity returns the specificity
func TrueNegatives ¶
TrueNegatives returns the number of true negative predicted values.
func TruePositivies ¶
TruePositivies returns the number of true positive predicted values.
func ZeroInitializer ¶
ZeroInitializer returns the zeros initializer for the bias initialization
Types ¶
type BatchNormLayer ¶
type BatchNormLayer struct {
// contains filtered or unexported fields
}
BatchNormLayer layer
func (*BatchNormLayer) Call ¶
func (bn *BatchNormLayer) Call() []float64
Call for the batch normalization layer
type CallbackHistory ¶
type CallbackHistory struct {
// contains filtered or unexported fields
}
CallbackHistory struct
func (*CallbackHistory) ReadToStrings ¶
func (ch *CallbackHistory) ReadToStrings() ([]string, error)
ReadToStrings returns history in strings.
type DenseLayer ¶
type DenseLayer struct { Activation func(float64) float64 KernelInit func(float64) float64 BiasInit func(float64) float64 // contains filtered or unexported fields }
DenseLayer defines a fully connected layer.
func Dense ¶
func Dense(units int, inputs []float64, activation func(float64) float64) DenseLayer
Dense fully connected layer initializer
func (DenseLayer) Call ¶
func (d DenseLayer) Call() []float64
Call of the dense layer.Outputs the next tensors.
func (DenseLayer) GetBiases ¶
func (d DenseLayer) GetBiases() matrix.Vector
GetBiases returns the layer's biases.
func (DenseLayer) GetWeights ¶
func (d DenseLayer) GetWeights() matrix.Matrix
GetWeights returns the layer's weights.
func (*DenseLayer) SetBiases ¶
func (d *DenseLayer) SetBiases(bs matrix.Vector)
SetBiases is used for manually defining the bias vector.
func (*DenseLayer) SetWeights ¶
func (d *DenseLayer) SetWeights(kernels matrix.Matrix)
SetWeights is used for manually defining the weight matrix.
func (DenseLayer) TrainableParameters ¶
func (d DenseLayer) TrainableParameters() int
TrainableParameters returns the count of trainable parameters.
type DropoutLayer ¶
type DropoutLayer struct {
// contains filtered or unexported fields
}
DropoutLayer layer
type EarlyStopper ¶
type EarlyStopper struct {
// contains filtered or unexported fields
}
EarlyStopper callback
type FlattenLayer ¶
type FlattenLayer struct {
// contains filtered or unexported fields
}
FlattenLayer layer
type InputLayer ¶
type InputLayer struct {
// contains filtered or unexported fields
}
InputLayer layer, much like the keras one.
type JSONLoader ¶
type JSONLoader struct {
// contains filtered or unexported fields
}
type Layer ¶
type Layer interface { Call() []float64 GetWeights() matrix.Matrix GetBiases() matrix.Vector Name() string TrainableParameters() int }
Layer interface given these 5 functions which every layer must have.
type Metrics ¶
Metrics is an interface that requires two functions, Measure and Name and is passed to the model.compile method.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model implements the model architecure.
func Sequential ¶
Sequential returns a model given layers and a name.
func (*Model) CallbackList ¶
CallbackList returns model's callback list
func (*Model) EarlyStopping ¶
EarlyStopping is much like the keras EarlyStopping callback. Index is the number in the model metrics attribute. Look it up under model.get_metrics()
func (*Model) GetLayerByIndex ¶
GetLayerByIndex returns the ith layer.
func (*Model) GetLayerByName ¶
GetLayerByName returns the layer given its name.
func (*Model) GetMetricsByIndex ¶
GetMetricsByIndex returns the index's model metric
func (*Model) History ¶
func (m *Model) History(filepath string) (*CallbackHistory, error)
History for model checkpointing
func (*Model) LearningRateScheduler ¶
LearningRateScheduler defined by fn
func (*Model) ModelCheckpoint ¶
ModelCheckpoint callback
func (*Model) Summary ¶
func (m *Model) Summary()
Summary prints the layer by layer summaary along with trainable parameters.
func (*Model) Train ¶
Train trains the model given trainX and trainY data and the number of epochs. It keeps track of the defined metrics and prints it every epoch. It also prints the training duration. It returns a map from strings to floats, where strings represent the metrics name and float the metrics value.
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network defines the neural network.
func InitNetwork ¶
InitNetwork initializes the network with the number of nodes and the learning rate.
type Optimizer ¶
type Optimizer interface {
ApplyGradients()
}
Optimizer interface requires an ApplyGradients function. Pass it to the model compilation.
type ReduceLearningRateOnPlateau ¶
type ReduceLearningRateOnPlateau struct {
// contains filtered or unexported fields
}
ReduceLearningRateOnPlateau callback
func (*ReduceLearningRateOnPlateau) ReduceLr ¶
func (rlr *ReduceLearningRateOnPlateau) ReduceLr(m *Model, at int)
ReduceLr callback
type SoftmaxLayer ¶
type SoftmaxLayer struct {
// contains filtered or unexported fields
}
SoftmaxLayer layer
func Softmax ¶
func Softmax(inputs []float64, classes int) SoftmaxLayer
Softmax returns the softmax layer based on values.
type TrainingLog ¶
type TrainingLog struct {
// contains filtered or unexported fields
}
TrainingLog returns model's log