mindspore.load_param_into_net

mindspore.load_param_into_net(net, parameter_dict, strict_load=False)[source]

Load parameters into network.

Parameters
  • net (Cell) – The network where the parameters will be loaded.

  • parameter_dict (dict) – The dictionary generated by load checkpoint file.

  • strict_load (bool) – Whether to strict load the parameter into net. If False, it will load parameter into net when parameter name’s suffix in checkpoint file is the same as the parameter in the network. When the types are inconsistent perform type conversion on the parameters of the same type, such as float32 to float16. Default: False.

Returns

List, parameter name not loaded into the network

Raises

TypeError – Argument is not a Cell, or parameter_dict is not a Parameter dictionary.

Examples

>>> from mindspore import load_checkpoint, load_param_into_net
>>>
>>> net = Net()
>>> ckpt_file_name = "./checkpoint/LeNet5-1_32.ckpt"
>>> param_dict = load_checkpoint(ckpt_file_name, filter_prefix="conv1")
>>> param_not_load = load_param_into_net(net, param_dict)
>>> print(param_not_load)
['conv1.weight']