Closed TFUsers closed 7 years ago
This python3 compatibility problem has been fixed in commit 3fb21a2. Thanks.
Can you git clone https://github.com/clcarwin/convert_torch_to_pytorch again? This is my test log:
root@bd9dbca8e3c2:/home/convert_torch_to_pytorch# python3 convert_torch.py -m resnext_50_32x4d.t7 root@bd9dbca8e3c2:/home/convert_torch_to_pytorch# python3 Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.
import torch import torch.backends.cudnn as cudnn import resnext_50_32x4d as resnext import numpy as np net = resnext.resnext_50_32x4d net.load_state_dict(torch.load('resnext_50_32x4d.pth')) net.eval() data = torch.from_numpy(np.ones((2,3,224,224)).astype(np.float32)) data = torch.autograd.Variable(data, volatile=True) output = net(data) print(output) Variable containing: -0.9238 -0.1465 -1.2855 ... -1.3550 0.1185 0.4868 -0.9238 -0.1465 -1.2855 ... -1.3550 0.1185 0.4868 [torch.FloatTensor of size 2x1000]
On Thu, May 11, 2017 at 4:12 PM, TFUsers notifications@github.com wrote:
This does not resolve the issue for me. Here is a minimal example:
import torchimport torch.backends.cudnn as cudnnimport resnext_50_32x4d as resnextimport numpy as np
ngpu = 1 np.random.seed(1)
net = resnext.resnext_50_32x4d net.load_state_dict(torch.load('./convert/resnext_50_32x4d.pth')) print(net) if ngpu > 1: net = torch.nn.DataParallel(net, device_ids=list(range(ngpu))) if ngpu > 0: net.cuda()
torch.manual_seed(1)if ngpu > 0: torch.cuda.manual_seed(1)
optimizer = torch.optim.SGD(filter(lambda p: p.requires_grad, net.parameters()), 0.1, momentum=0.9, weight_decay=0.0005)
cudnn.benchmark = True # fire on all cylinders
net.train() # enter train mode loss_avg = 0.0
data = torch.from_numpy(np.random.normal(size=(64,3,224,224)).astype(np.float32)) data = torch.autograd.Variable(data.cuda(), volatile=True)
output = net(data)
Here is the model's python file (converted to txt to enable uploading). resnext_50_32x4d.txt https://github.com/clcarwin/convert_torch_to_pytorch/files/992275/resnext_50_32x4d.txt
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/clcarwin/convert_torch_to_pytorch/issues/7#issuecomment-300715596, or mute the thread https://github.com/notifications/unsubscribe-auth/AAxYDbX2lbDGKVQBeJg6lXuJHWWroOJTks5r4sLRgaJpZM4NTA-u .
I converted a ResNeXt-50 (32x4d) with this script but upon running the model I obtain the error
I suspect this is because I am using python 3, where functional methods differ from version 2. Is there an easy fix to this problem?