RecipeCompat

class ketos.neural_networks.dev_utils.nn_interface.RecipeCompat(recipe_name, template, **kwargs)[source]

Makes a loss function, metric or optimizer compatible with the Ketos recipe format.

The resulting object can be included in a ketos recipe and read by the NNInterface (or it’s subclasses)

Args:
recipe_name: str

The name to be used in the recipe

template: constructor

The loss function, metric or optimizer constructor

kwargs

Any keyword arguments to be passed to the constructor (func)

Returns:

A RecipeCompat object

Examples:
>>> # Example Metric
>>> p = tf.keras.metrics.Precision
>>> dec_p = RecipeCompat("precision", p)
>>> # Example Optimizer
>>> opt = tf.keras.optimizers.Adam
>>> dec_opt = RecipeCompat("adam", opt, learning_rate=0.001)
>>> # Example Loss
>>> loss = tf.keras.losses.BinaryCrossentropy
>>> dec_loss = RecipeCompat('binary_crossentropy', loss, from_logits=True)

Methods

instantiate_template(**template_kwargs)

instantiate_template(**template_kwargs)[source]