Evaluation Strategy#
(hivenas.core.nas.evaluation_strategy)
The Evaluation Strategy phase of the NAS framework.
- class NASEval(config)[source]#
Bases:
objectResponsible for instantiating and evaluating candidate architectures
- config#
the predefined operational parameters pertaining to evaluation (defined in
evaluation_strategy_config)- Type
dict
- datagen#
the data generator used to train all candidates (instantiated once to preserve resources)
- Type
tensorflow.keras.preprocessing.image.ImageDataGenerator
- model#
the candidate model to be evaluated (overwritten and deleted with every evaluation process to prevent leaks)
- Type
Model
- evaluate(arch)[source]#
Evaluates the candidate architecture given a string-encoded representation of the model
- Parameters
arch (list) – a list of architecture operations ([str]), encoded by
NASSearchSpace- Returns
a dictionary containing all relevant results to be saved, including: fitness, number of training epochs conducted (in case of ACT), hashed file name, number of trainable parameters, and the last epoch’s momentum value if applicable
- Return type
dict
- fully_train(model_file=None, arch=None)[source]#
Loads and continues training of a partially-trained model using either a string-encoded architecture (instantiates the model and trains from scratch) or a model h5 file
- Parameters
model_file (str, optional) – a previously saved h5 model file (continues training)
arch (list, optional) – a list of architecture operations ([str]), encoded by
NASSearchSpace
- Returns
a dictionary containing all relevant results to be saved, including: fitness, number of training epochs conducted (not including any previous trainings), hashed file name, number of trainable parameters
- Return type
dict
- get_weights_filename(arch)[source]#
Hashes the architecture op-list into a unique filename using SHA1
- Parameters
arch (list) – a list of architecture operations ([str]), encoded by
NASSearchSpace- Returns
SHA1-hashed unique string ID for the given architecture
- Return type
str
- instantiate_network(arch)[source]#
Instantiates a Keras network given an architecture op list
- Parameters
arch (list) – a list of architecture operations ([str]), encoded by
NASSearchSpace
- momentum_training(weights_file, m_epochs)[source]#
Loads and continues training of a partially-trained model
- Parameters
weights_file (str) – the previously saved h5 model file (continues training)
m_epochs (int) – number of momentum epochs to continue training for
- Returns
final fitness value (accuracy) after training continuation
- Return type
dict