我们如何将t7模型转换为keras‘h5?我试着这样做是为了c3d-sports1m-kinetics.t7,你可以在这里找到https://github.com/kenshohara/3D-ResNets/releases
我可以要求的至少是一种将t7模型加载到python的方法,然后提取它的权重,但是我不能用load_lua()函数来实现.
我试图使用这个函数file.py执行时出错。
我得到的错误如下:
Traceback (most recent call last):
File "convert_t7_to_hdf5.py", line 574, in <module>
a = load_lua("model.t7")
File "convert_t7_to_hdf5.py", line 571, in load_lua
return reader.read()
File "convert_t7_to_hdf5.py", line 542, in read
typeidx = self.read_int()
File "convert_t7_to_hdf5.py", line 440, in read_int
return self._read('i')
File "convert_t7_to_hdf5.py", line 431, in _read
result = struct.unpack(fmt, self.f.read(sz))
ValueError: read of closed file发布于 2019-03-13 17:54:41
如本链接所述,https://github.com/pytorch/pytorch/issues/15307#issuecomment-448086741
使用火炬文件包,加载是成功的。您可以将模型的内容转储到文件中,然后了解内容。每一层信息都以字典的形式存储。了解模型体系结构将使解析内容变得更容易。
>>> import torchfile
>>> model = torchfile.load('c3d-sports1m-kinetics.t7')
>>> module = model.modules[0].modules[0]
>>> module.name
b'conv1a'
>>> module['weight'].shape
(64, 3, 3, 3, 3)
>>> module['bias'].shape
(64,)https://stackoverflow.com/questions/55147282
复制相似问题