添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

load_state_dict ( state_dict , strict=True ) [source]

Copies parameters and buffers from state_dict into this module and its descendants. If strict is True , then the keys of state_dict must exactly match the keys returned by this module’s state_dict() function.

Parameters

  • state_dict ( dict ) – a dict containing parameters and persistent buffers.

  • strict ( bool , optional ) – whether to strictly enforce that the keys in state_dict match the keys returned by this module’s state_dict() function. Default: True

Returns

  • missing_keys is a list of str containing the missing keys

  • unexpected_keys is a list of str containing the unexpected keys

Return type

NamedTuple with missing_keys and unexpected_keys fields

Error(s) pytorch 加载checkpoint state_dict出错:Missing key(s) && Unexpected key(s) in state_dict

ERROR:Traceback (most recent call last):File "test_0.py", line 130, in model = load_model()File "test_0.py", line 104, in load_modelmodel.load_state_dict(checkpoint['state_dict'])File "/home/...