The error code is as follows:
# Error code!
model = model.load_state_dict(state_dict_var)
out = model(input)
There are some problems on the Internet because the saved model uses state_ DCIT() to load, or vice versa.
The error here is different from the above because xxx.load_state_Dict() does not require a return value to receive.
Amend to read as follows:
# Correct code!
model.load_state_dict(state_dict_var)
out = model(input)
I hope it will help more people.
Read More:
- [Solved] AttributeError: ‘_IncompatibleKeys‘ object has no attribute ‘parameters‘
- [Solved] AttributeError: ‘DataParallel‘ object has no attribute ‘save‘
- [Solved] Pytorch-transformers Error: AttributeError: ‘str‘ object has no attribute ‘shape‘
- [Solved] AttributeError: ‘DataFrame‘ object has no attribute ‘tolist‘
- [Solved] AttributeError: ‘NoneType‘ object has no attribute ‘astype‘
- [Solved] AttributeError: ‘str‘ object has no attribute ‘decode‘
- AttributeError: DatetimeProperties object has no attribute
- [Solved] AttributeError: ‘DataFrame‘ object has no attribute ‘map‘
- [Solved] AttributeError: DataFrame object has no attribute’xxx’
- [Solved] AttributeError: ‘NoneType‘ object has no attribute ‘append‘
- [Solved] AttributeError: ‘HTMLWriter‘ object has no attribute ‘_temp_names‘
- [Solved] Python Keras Error: AttributeError: ‘Sequential‘ object has no attribute ‘predict_classes‘
- [Solved] AttributeError: ‘str‘ object has no attribute ‘decode‘
- [Solved] AttributeError: ‘PngImageFile‘ object has no attribute ‘imshow‘
- [Solved] AttributeError WriteOnlyWorksheet object has no attribute cell
- [Modified] AttributeError: ‘socket‘ object has no attribute ‘ioctl‘ python linux
- Python Openyxl Error: AttributeError: ‘int‘ object has no attribute ‘upper‘ [How to Solve]
- [Solved] Pytorch Error: AttributeError: ‘Tensor‘ object has no attribute ‘backword‘
- [Solved] Paramiko error: AttributeError: ‘NoneType’ object has no attribute ‘time’
- [Solved] django AttributeError: ‘UserComment‘ object has no attribute ‘save‘