spaic.Library package

Submodules

spaic.Library.Library module

spaic.Library.Network_loader module

spaic.Library.Network_saver module

Created on 2020/8/17 @project: SPAIC @filename: Network_saver @author: Mengxiao Zhang @contact: mxzhangice@gmail.com

@description: 对既定格式网络的存储

spaic.Library.Network_saver.network_save(Net: Assembly, filename=None, path=None, trans_format='json', combine=False, save=True, save_weight=True)[source]

Save network to files.

Parameters:
  • Net (Assembly) – The network needed to be saved.

  • filename (Str) – The filename of the file that save target network.

  • trans_format (str) – The format of file, could be ‘json’ or ‘yaml’

  • combine (Boolen) – Whether combine weight and structure of the Network into on file, False by default.

  • save (Boolen) – Whether need to save the structure.

Returns:

The filename of the file we save network, since it

will give an auto name if no name given.

Return type:

filename(str)

Examples

>>> save_file = network_save(Net, "TestNetwork", trans_format='yaml', combine=True, save=True)
("TestNetwork", a dict of the structure of the network)
or
>>> save_file = network_save(Net, "TestNetwork", trans_format='json', combine=True, save=False)
a dict of the structure of the network
spaic.Library.Network_saver.trans_net(Net: Assembly, path: str, combine: bool, save: bool, save_weight: bool, diff_para_dict)[source]

Transform the structure of the network for saving.

Parameters:
  • Net (Assembly) – target network.

  • path (string) – Target path for saving net data.

Returns:

the result diction of the whole Network.

Return type:

result_dict(dictionary)

Example

yaml_net = trans_net(Net)

spaic.Library.Network_saver.trans_node(node: Node)[source]
Transform the structure of the Node layer for saving and extract the

parameters.

Parameters:

node (Node) – target node layer, like input layer and output layer

Returns:

the result diction with necessary

parameters of the layer.

Return type:

result_dict (dictionary)

spaic.Library.Network_saver.trans_layer(layer: NeuronGroup, diff_para_dict=None)[source]
Transform the structure of the layer for saving and extract the

parameters.

Parameters:

layer (NeuronGroup) – target layer

Returns:

the result diction with necessary

parameters of the layer.

Return type:

result_dict (dictionary)

spaic.Library.Network_saver.trans_projection(projection: Projection, combine: bool, save_weight: bool)[source]
Transform the structure of the projection for saving and extract the

parameters.

Parameters:

projection (Projection) – target projection

Returns:

the result diction with necessary

parameters of the projection.

Return type:

result_dict (dictionary)

spaic.Library.Network_saver.trans_connection(connection: Connection, combine: bool, save_weight: bool)[source]
Transform the structure of the connection for saving and extract the

parameters.

Parameters:
  • connection (Connection) – target connection

  • combine (bool) – whether combine weights.

Returns:

the result diction with necessary

parameters of the connection.

Return type:

result_dict (dictionary)

spaic.Library.Network_saver.trans_backend(backend: Backend, save: bool, diff_para_dict=None)[source]

Transform the data of backend for saving.

Parameters:
  • backend – target backend.

  • path (string) – Target path for saving net data.

Returns:

Contain the parameters of backend to be saved.

Return type:

result(dict)

spaic.Library.Network_saver.trans_learner(learner, learn_name)[source]

Transform learner parameters to dict. :param learner: Target learner with needed parameters.

Returns:

Contain the parameters of learner to be saved.

Return type:

result(dict)

spaic.Library.Network_saver.trans_monitor(monitor: Monitor)[source]

Transform monitor to dict. :param learner: Target learner with needed parameters.

Returns:

Contain the parameters of learner to be saved.

Return type:

result(dict)

spaic.Library.Network_saver.check_var_type(var)[source]
spaic.Library.Network_saver.trans_bias(para: dict)[source]

spaic.Library.STCA_music_network module

Module contents