如何在PyTorch中使用.mat格式的模型?

huangapple go评论61阅读模式
英文:

How can I use a model of format .mat in PyTorch?

问题

我已经从 https://www.di.ens.fr/willow/research/netvlad/ 下载了一个经过训练的NetVLAD模型。然而,该模型是在MatLab中训练的,文件类型是*.mat*。我应该如何在PyTorch中加载它呢?

我能够使用以下代码访问权重,但是我不确定接下来该怎么做。是否有一种方法可以使用load_state_dict或类似的方法在PyTorch中加载它?

from scipy.io import loadmat

data = loadmat('vd16_pitts30k_conv5_3_vlad_preL2_intra_white.mat')

array_data = data['net']
英文:

I've downloaded a trained NetVLAD model from https://www.di.ens.fr/willow/research/netvlad/.
However, the model was trained in MatLab and is of the type .mat.
How can I load this in PyTorch?

I was able to access the weights using the following code, but I'm not sure how to proceed from this point. Is there a way to load this in PyTorch with load_state_dict or something similar?

from scipy.io import loadmat

data = loadmat('vd16_pitts30k_conv5_3_vlad_preL2_intra_white.mat')

array_data = data['net']

答案1

得分: 1

权重对于网络的结构没有任何信息,它只是一个数字数组。如果你恰好有与MATLAB相同的网络,并且知道如何放置每个数字,那么是的,你可以做到,但没有“直接和简单”的方法。

英文:

The weights have zero information about the structure of the network, its just an array of numbers. If you happen to have exactly the same network than MATLAB had, and know where to put each number, yes, you can do it, but there is no "direct and easy" way.

huangapple
  • 本文由 发表于 2023年7月23日 18:11:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76747698.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定