# neupy.storage module

neupy.storage.save(network, filepath)[source]

Save network parameters in HDF5 format.

Parameters: network : network, list of layer or network filepath : str Path to the HDF5 file that stores network parameters.

Examples

>>> from neupy import layers, storage
>>>
>>> network = layers.Input(10) > layers.Softmax(3)
>>> storage.save_hdf5(network, '/path/to/parameters.hdf5')


Load network parameters from HDF5 file.

Parameters: network : network, list of layer or network filepath : str Path to HDF5 file that will store network parameters. ignore_missing : bool False means that error will be triggered in case if some of the layers doesn’t have storage parameters in the specified source. Defaults to False. load_by : {names, order, names_or_order} Defines strategy that will be used during parameter loading names - Matches layers in the network with stored layer using their names. order - Matches layers in the network with stored layer using exect order of layers. names_or_order - Matches layers in the network with stored layer trying to do it first using the same names and then matching them sequentialy. Defaults to names_or_order. skip_validation : bool When set to False validation will be applied per each layer in order to make sure that there were no changes between created and stored models. Defaults to True ValueError Happens in case if ignore_missing=False and there is no parameters for some of the layers.

Examples

>>> from neupy import layers, storage
>>>
>>> network = layers.Input(10) > layers.Softmax(3)

neupy.storage.save_pickle(network, filepath, python_compatible=False)[source]

Save layer parameters in pickle file.

Parameters: network : network, list of layer or network filepath : str Path to the pickle file that stores network parameters. python_compatible : bool If True pickled object would be compatible with Python 2 and 3 (pickle protocol equal to 2). If False then value would be pickled as highest protocol (pickle.HIGHEST_PROTOCOL). Defaults to False.

Examples

>>> from neupy import layers, storage
>>>
>>> network = layers.Input(10) > layers.Softmax(3)
>>> storage.save_pickle(network, '/path/to/parameters.pickle')


Load and set parameters for layers from the specified filepath.

Parameters: network : network, list of layer or network filepath : str Path to pickle file that will store network parameters. ignore_missing : bool False means that error will be triggered in case if some of the layers doesn’t have storage parameters in the specified source. Defaults to False. load_by : {names, order, names_or_order} Defines strategy that will be used during parameter loading names - Matches layers in the network with stored layer using their names. order - Matches layers in the network with stored layer using exect order of layers. names_or_order - Matches layers in the network with stored layer trying to do it first using the same names and then matching them sequentialy. Defaults to names_or_order. skip_validation : bool When set to False validation will be applied per each layer in order to make sure that there were no changes between created and stored models. Defaults to True ValueError Happens in case if ignore_missing=False and there is no parameters for some of the layers.

Examples

>>> from neupy import layers, storage
>>>
>>> network = layers.Input(10) > layers.Softmax(3)

neupy.storage.save_json(network, filepath, indent=None)[source]

Save network parameters in JSON format.

Parameters: network : network, list of layer or network filepath : str Path to the JSON file that stores network parameters. indent : int or None Indentation that would be specified for the output JSON. Intentation equal to 2 or 4 makes it easy to read raw text files. The None value disables indentation which means that everything will be stored compactly. Defaults to None.

Examples

>>> from neupy import layers, storage
>>>
>>> network = layers.Input(10) > layers.Softmax(3)
>>> storage.save_json(network, '/path/to/parameters.json')


Load network parameters from JSON file.

Parameters: network : network, list of layer or network filepath : str Path to JSON file that will store network parameters. ignore_missing : bool False means that error will be triggered in case if some of the layers doesn’t have storage parameters in the specified source. Defaults to False. load_by : {names, order, names_or_order} Defines strategy that will be used during parameter loading names - Matches layers in the network with stored layer using their names. order - Matches layers in the network with stored layer using exect order of layers. names_or_order - Matches layers in the network with stored layer trying to do it first using the same names and then matching them sequentialy. Defaults to names_or_order. skip_validation : bool When set to False validation will be applied per each layer in order to make sure that there were no changes between created and stored models. Defaults to True ValueError Happens in case if ignore_missing=False and there is no parameters for some of the layers.

Examples

>>> from neupy import layers, storage
>>>
>>> network = layers.Input(10) > layers.Softmax(3)

neupy.storage.save_hdf5(network, filepath)[source]

Save network parameters in HDF5 format.

Parameters: network : network, list of layer or network filepath : str Path to the HDF5 file that stores network parameters.

Examples

>>> from neupy import layers, storage
>>>
>>> network = layers.Input(10) > layers.Softmax(3)
>>> storage.save_hdf5(network, '/path/to/parameters.hdf5')


Load network parameters from HDF5 file.

Parameters: network : network, list of layer or network filepath : str Path to HDF5 file that will store network parameters. ignore_missing : bool False means that error will be triggered in case if some of the layers doesn’t have storage parameters in the specified source. Defaults to False. load_by : {names, order, names_or_order} Defines strategy that will be used during parameter loading names - Matches layers in the network with stored layer using their names. order - Matches layers in the network with stored layer using exect order of layers. names_or_order - Matches layers in the network with stored layer trying to do it first using the same names and then matching them sequentialy. Defaults to names_or_order. skip_validation : bool When set to False validation will be applied per each layer in order to make sure that there were no changes between created and stored models. Defaults to True ValueError Happens in case if ignore_missing=False and there is no parameters for some of the layers.

Examples

>>> from neupy import layers, storage
>>>
>>> network = layers.Input(10) > layers.Softmax(3)


Parameters: network : network, list of layer or network data : dict Dictionary that stores network parameters. ignore_missing : bool False means that error will be triggered in case if some of the layers doesn’t have storage parameters in the specified source. Defaults to False. load_by : {names, order, names_or_order} Defines strategy that will be used during parameter loading names - Matches layers in the network with stored layer using their names. order - Matches layers in the network with stored layer using exect order of layers. names_or_order - Matches layers in the network with stored layer trying to do it first using the same names and then matching them sequentialy. Defaults to names_or_order. skip_validation : bool When set to False validation will be applied per each layer in order to make sure that there were no changes between created and stored models. Defaults to True ValueError Happens in case if ignore_missing=False and there is no parameters for some of the layers.
neupy.storage.save_dict(network)[source]

Save network into the dictionary.

Parameters: network : network, list of layer or network dict Saved parameters and information about network in dictionary using specific format. Learn more about the NeuPy’s storage format in the official documentation.

Examples

>>> from neupy import layers, storage
>>>
>>> network = layers.Input(10) >> layers.Softmax(3)
>>> layers_data = storage.save_dict(network)
>>>
>>> layers_data.keys()