npu.utils.keras_utils
Classes
- class npu.utils.keras_utils.KerasUtils
- Author:
Alberto M. Esmoris Pena
Class with util static methods to extend Keras functionalities.
- static merge_history(a, b)
Merge history a with history b. Note that history a must be chronologically before history b so the values can be properly sorted over time.
- Parameters:
a – The first training history (also chronologically predecessor of history b).
b – The second training history (also chronologically successor of history a).
- Returns:
The merged history (which is the history a again because it is updated in place).
- static set_learning_rate(nn, lr)
Set the learning rate of a compiled neural network.
- Parameters:
nn – The neural network whose learning rate must be set.
lr (float) – The new learning rate for the neural network.
- Returns:
The neural network itself (which is updated in place), for fluent programming purposes.
- static handle_h5_layer_rename(layer, cache)
Handle the renaming of a layer to make it compatible with the Keras naming convention for HDF5 files (which is based on snake case). The first time a given type of layer (where the type is given by the class), the renaming consists of the snake case version of the class name. The second time, the name is the same but appending _1 at the end, the third time appending _2, and so on.
- Parameters:
layer – The layer whose HDF5 name must be computed.
cache (dict) – The cache to track already named layers. It will be updated for each call to this function. The keys are the class names, the values how many times it has been used.
- Returns:
The new name for the class compatible with Keras HDF5 naming convention.
- Return type:
str