ml_genn.losses package
Loss functions are used to compute the quantity that a
model should seek to minimize during training. For supervised
learning tasks, these are based on some labels and the prediction
obtained from a model using a ml_genn.readouts.Readout
- class ml_genn.losses.Loss
Bases:
ABC
Base class for all loss functions
- abstract add_to_neuron(model, shape, batch_size, example_timesteps)
Modify a neuron model, adding any additional state and functionality required to implement this loss function.
- Parameters:
model (NeuronModel) – Neuron model to modify (in place)
shape – Shape of population loss is calculated for
batch_size (int) – Batch size of model used with loss function
example_timesteps (int) – How many timestamps each example will be presented to the network for
- abstract set_target(genn_pop, y_true, shape, batch_size, example_timesteps)
Write the current target output value to the compiled neuron group.
- Parameters:
genn_pop – GeNN
NeuronGroup
object population with loss function has been compiled intoy_true – ‘true’ values provided to compiled network train method
shape – Shape of population loss is calculated for
batch_size (int) – Batch size of model used with loss function
example_timesteps (int) – How many timestamps each example will be presented to the network for
- class ml_genn.losses.MeanSquareError
Bases:
Loss
Computes the mean squared error between labels and prediction
- add_to_neuron(model, shape, batch_size, example_timesteps)
Modify a neuron model, adding any additional state and functionality required to implement this loss function.
- Parameters:
model (NeuronModel) – Neuron model to modify (in place)
shape – Shape of population loss is calculated for
batch_size (int) – Batch size of model used with loss function
example_timesteps (int) – How many timestamps each example will be presented to the network for
- set_target(genn_pop, y_true, shape, batch_size, example_timesteps)
Write the current target output value to the compiled neuron group.
- Parameters:
genn_pop – GeNN
NeuronGroup
object population with loss function has been compiled intoy_true – ‘true’ values provided to compiled network train method
shape – Shape of population loss is calculated for
batch_size (int) – Batch size of model used with loss function
example_timesteps (int) – How many timestamps each example will be presented to the network for
- class ml_genn.losses.SparseCategoricalCrossentropy
Bases:
Loss
Computes the crossentropy between labels and prediction when there are two or more label classes, specified as integers.
- add_to_neuron(model, shape, batch_size, example_timesteps)
Modify a neuron model, adding any additional state and functionality required to implement this loss function.
- Parameters:
model (NeuronModel) – Neuron model to modify (in place)
shape – Shape of population loss is calculated for
batch_size (int) – Batch size of model used with loss function
example_timesteps (int) – How many timestamps each example will be presented to the network for
- set_target(genn_pop, y_true, shape, batch_size, example_timesteps)
Write the current target output value to the compiled neuron group.
- Parameters:
genn_pop – GeNN
NeuronGroup
object population with loss function has been compiled intoy_true – ‘true’ values provided to compiled network train method
shape – Shape of population loss is calculated for
batch_size (int) – Batch size of model used with loss function
example_timesteps (int) – How many timestamps each example will be presented to the network for