remove unused Keras load/save helpers
@@ -31,59 +31,6 @@ class _ArgsWrapper(object):
return self.args.get(name)
-def save_model(model, dir, filename, weights_only=False):
- """
- Save Keras model
- :param model:
- :param dir:
- :param filename:
- :param weights_only:
- :return:
- """
- # If target directory does not exist, create
- if not os.path.exists(dir):
- os.makedirs(dir)
-
- # Construct full path
- filepath = os.path.join(dir, filename)
-
- if weights_only:
- # Dump model weights
- model.save_weights(filepath)
- print("Model weights were saved to: " + filepath)
- else:
- # Dump model architecture and weights
- model.save(filepath)
- print("Model was saved to: " + filepath)
-
-
-def load_model(directory, filename, weights_only=False, model=None):
- """
- Loads Keras model
- :param directory:
- :param filename:
- :return:
- """
-
- # If restoring model weights only, make sure model argument was given
- if weights_only:
- assert model is not None
-
- # Construct full path to dumped model
- filepath = os.path.join(directory, filename)
-
- # Check if file exists
- assert os.path.exists(filepath)
-
- # Return Keras model
- if weights_only:
- result = model.load_weights(filepath)
- print(result)
- return model.load_weights(filepath)
- else:
- return keras.models.load_model(filepath)
-
-
def batch_indices(batch_nb, data_length, batch_size):
"""
This helper function computes a batch start and end index
