exarl.candlelib.keras_utils

Module Contents

Classes

PermanentDropout

LoggingCallback

MultiGPUCheckpoint

Functions

set_parallelism_threads()

Set the number of parallel threads according to the number available on the hardware

set_seed(seed)

Set the random number seed to the desired value

get_function(name)

build_optimizer(type, lr, kerasDefaults)

Set the optimizer to the appropriate Keras optimizer function

build_initializer(type, kerasDefaults, seed=None, constant=0.0)

Set the initializer to the appropriate Keras initializer function

build_loss(loss_type, kerasDefaults, reduction='auto')

xent(y_true, y_pred)

r2(y_true, y_pred)

mae(y_true, y_pred)

mse(y_true, y_pred)

covariance(x, y)

corr(y_true, y_pred)

evaluate_autoencoder(y_pred, y_test)

register_permanent_dropout()

exarl.candlelib.keras_utils.set_parallelism_threads()

Set the number of parallel threads according to the number available on the hardware

exarl.candlelib.keras_utils.set_seed(seed)

Set the random number seed to the desired value

Parameters

seed (integer) – Random number seed.

exarl.candlelib.keras_utils.get_function(name)
exarl.candlelib.keras_utils.build_optimizer(type, lr, kerasDefaults)

Set the optimizer to the appropriate Keras optimizer function based on the input string and learning rate. Other required values are set to the Keras default values

Parameters
  • type (string) –

    String to choose the optimizer

    Options recognized: ‘sgd’, ‘rmsprop’, ‘adagrad’, adadelta’, ‘adam’ See the Keras documentation for a full description of the options

  • lr (float) – Learning rate

  • kerasDefaults (list) – List of default parameter values to ensure consistency between frameworks

Returns

The appropriate Keras optimizer function

exarl.candlelib.keras_utils.build_initializer(type, kerasDefaults, seed=None, constant=0.0)

Set the initializer to the appropriate Keras initializer function based on the input string and learning rate. Other required values are set to the Keras default values

Parameters
  • type (string) –

    String to choose the initializer

    Options recognized: ‘constant’, ‘uniform’, ‘normal’, ‘glorot_uniform’, ‘lecun_uniform’, ‘he_normal’

    See the Keras documentation for a full description of the options

  • kerasDefaults (list) – List of default parameter values to ensure consistency between frameworks

  • seed (integer) – Random number seed

  • constant (float) – Constant value (for the constant initializer only)

Returns

The appropriate Keras initializer function

exarl.candlelib.keras_utils.build_loss(loss_type, kerasDefaults, reduction='auto')
exarl.candlelib.keras_utils.xent(y_true, y_pred)
exarl.candlelib.keras_utils.r2(y_true, y_pred)
exarl.candlelib.keras_utils.mae(y_true, y_pred)
exarl.candlelib.keras_utils.mse(y_true, y_pred)
exarl.candlelib.keras_utils.covariance(x, y)
exarl.candlelib.keras_utils.corr(y_true, y_pred)
exarl.candlelib.keras_utils.evaluate_autoencoder(y_pred, y_test)
class exarl.candlelib.keras_utils.PermanentDropout(rate, **kwargs)

Bases: tensorflow.keras.layers.Dropout

call(self, x, mask=None)
exarl.candlelib.keras_utils.register_permanent_dropout()
class exarl.candlelib.keras_utils.LoggingCallback(print_fcn=print)

Bases: tensorflow.keras.callbacks.Callback

on_epoch_end(self, epoch, logs={})
class exarl.candlelib.keras_utils.MultiGPUCheckpoint

Bases: tensorflow.keras.callbacks.ModelCheckpoint

set_model(self, model)