prevision_quantum_nn.models.utilities.early_stopper

early stopper module

Module Contents

Classes

EarlyStopper

Class EarlyStopper.

class prevision_quantum_nn.models.utilities.early_stopper.EarlyStopper(window=10)

Class EarlyStopper.

Used to early stop the convergence of the quantum neural network

window

early stopper window or patience

Type

int

val_losses

list of validation losses to be kept in memory

Type

list

best_var

the best set of weights that yielded the minimum loss in the window

Type

list

best_val_loss

best validation loss so far in the window

Type

float

buffer

keeps the weights of the models until early stopper criterion is met

Type

queue

add_validation_loss(self, loss)

Adds validation loss to loss buffer.

Also stores the best loss reached so far.

Parameters

loss (float) – loss of the current iteration

get_stopping_criterion(self)

Stopping_criterions.

Returns

bool

True is algorithm should stop False if algorithm should continue

Return type

stopping_criterion

update(self, val_loss, var)

Updates the early stopper at a given iteration.

Parameters
  • val_loss (float) – validation loss to be stored

  • var – (list):list of weights that yielded this loss

Returns

bool

if True, the calculatino will stop

Return type

stopping_criterion

get_best_var(self)

Returns best weights.

Returns

list

list of best weights

Return type

best_var