Input/output

This page provides an overview of all the methods and functions that you can use to save, load and transfer models.

neuralfit.Model.save method

Saves the model in the sparse NeuralFit (.nf) format. Requires less memory than converting to Keras and then saving in for instance the .hdf5 format.
neuralfit.Model.save(path)
Parameters:
  • path: str
    Path to save the model to.

neurafit.load method

Loads a model from the sparse NeuralFit (.nf) format.

neuralfit.load(path)
Parameters:
  • path: str
    Path to a .nf file.
Returns:
  • neuralfit.Model
    A model.

neuralfit.Model.to_keras method

Convert the model to an equivalent Keras model. Note that there can be very small differences in the outputs of the NeuralFit and equivalent Keras model. Note that this method will automatically import Keras if not yet done. Note: it is not possible to convert recurrent Models to Keras. Please use model.save().
neuralfit.Model.to_keras()

Returns:

  • tf.keras.Model

    The equivalent Keras model.

neuralfit.from_keras method

Convert a Keras model to an equivalent NeuralFit model. Note that there can be very small differences in the outputs of the Keras and equivalent NeuralFit model. Currently it is only possible to convert Keras models that were previously NeuralFit models (i.e., they were created using to_keras()). In the future it will be possible to convert any Keras model.

neuralfit.Model.to_keras(keras_model)
Parameters:
  • keras_model: tf.keras.Model
    A keras model.
Returns:
  • neuralfit.Model
    An equivalent NeuralFit model.