Closed Dimanjan closed 2 weeks ago
The pretrained model in https://github.com/suragnair/alpha-zero-general/tree/master/pretrained_models/othello/keras cannot be loaded.
Code:
import torch model=torch.load("6x6 checkpoint_145.pth.tar",map_location='cpu')
Error Message:
--------------------------------------------------------------------------- UnpicklingError Traceback (most recent call last) Cell In [2], line 2 1 import torch ----> 2 model=torch.load("6x6 checkpoint_145.pth.tar",map_location='cpu') File c:\Users\entdi\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\serialization.py:713, in load(f, map_location, pickle_module, **pickle_load_args) 711 return torch.jit.load(opened_file) 712 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) --> 713 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args) File c:\Users\entdi\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\serialization.py:920, in _legacy_load(f, map_location, pickle_module, **pickle_load_args) 914 if not hasattr(f, 'readinto') and (3, 8, 0) <= sys.version_info < (3, 8, 2): 915 raise RuntimeError( 916 "torch.load does not work with file-like objects that do not implement readinto on Python 3.8.0 and 3.8.1. " 917 f"Received object of type \"{type(f)}\". Please update to Python 3.8.2 or newer to restore this " 918 "functionality.") --> 920 magic_number = pickle_module.load(f, **pickle_load_args) 921 if magic_number != MAGIC_NUMBER: 922 raise RuntimeError("Invalid magic number; corrupt file?") UnpicklingError: invalid load key, 'H'.
The models in other folders can be loaded with similar code, but not this one.
Also, why is this a .pth.tar file instead of .h5 ?
Sorry, if this is a naive question.
You're trying to load a keras model in PyTorch.
I just checked and I can load models in pretrained_models/othello/pytorch with py3.11, torch v2.5
pretrained_models/othello/pytorch
The pretrained model in https://github.com/suragnair/alpha-zero-general/tree/master/pretrained_models/othello/keras cannot be loaded.
Code:
Error Message:
The models in other folders can be loaded with similar code, but not this one.
Also, why is this a .pth.tar file instead of .h5 ?
Sorry, if this is a naive question.