utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupParameters

type BackupParameters struct {
	ToCreate bool
	Path     string
}

BackupParameters manages data associated to creating the dumps for an ANN.

ToCreate determines whether to create the dumps at all.

Path specifies the folder, where the dumps should be stored.

type NeuralNetworkParameters

type NeuralNetworkParameters struct {
	EpochCount uint64

	LearningRateDecay   float64
	InitialLearningRate float64
	WeightDecay         float64
	ClipValue           float64

	AccuracyMetric metric.Metric

	Backups BackupParameters
	// contains filtered or unexported fields
}

NeuralNetworkParameters containes some parameters to be applied to an ANN during its training.

EpochCount specifies the total epochs for the ANN to train. If not set, initialized to 5.

LearningRateDecay is used to degrade the learning rate after some epochs. Algorithm is based on the inverse of epochs passed during training.

InitialLearningRate is the starting value for the learning rate. If LearningRateDecay is 0, this learning rate is kept during the whole training.

WeightDecay is a L2 reguralization technique to enforce the model to improve weights using smaller absolute values. This helps in preventing gradient exploding and overfitting of the model, though if the value is too large can cause to underfit.

ClipValue is the absolute value by which the gradient must be clipped to reduce the sudden changes in the weights.

AccuracyMetric is a metric of calculating how many correct outputs were guessed during training. Output for this function is usually used in the logs for the epoch summary.

Backups is a struct containing backup variables to manages ANN dumps.

func (*NeuralNetworkParameters) IncrementEpoch

func (nnp *NeuralNetworkParameters) IncrementEpoch()

IncrementEpoch increments current epoch count by 1. Epoch count may influence the learning rate, based on learning rate decay.

func (NeuralNetworkParameters) LearningRate

func (nnp NeuralNetworkParameters) LearningRate() float64

LearningRate returns the current learning rate of the ANN. The return value of this funciton may depend on the epoch passed and learning rate decay value.

func (*NeuralNetworkParameters) ResetEpoch

func (nnp *NeuralNetworkParameters) ResetEpoch()

ResetEpoch resets current epoch count to 0. Epoch count may influence the learning rate, based on learning rate decay.

func (*NeuralNetworkParameters) Validate

func (nnp *NeuralNetworkParameters) Validate()

Validate updates the values of the hyperparameters to be valid. Currently updated parameters are:

  • InitialLearningRate: set to 0.01
  • EpochCount: set to 5
  • ClipValue: if not provided, set to +inf

Jump to

Keyboard shortcuts

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