I'm very new to pytorch I'm getting these errors when I run the test.py file
File "test.py", line 93, in
thresh=args.visual_threshold)
File "test.py", line 54, in test_net
y = net(x) # forward pass
File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/nn/modules/module.py", line 206, in __call__
result = self.forward(input, *kwargs)
File "/workspace/ssd.pytorch/ssd.py", line 102, in forward
self.priors # default boxes
File "/workspace/ssd.pytorch/layers/functions/detection.py", line 51, in forward
decoded_boxes = decode(loc_data[i], prior_data, self.variance)
File "/workspace/ssd.pytorch/layers/box_utils.py", line 152, in decode
priors[:, :2] + loc[:, :2] * variances[0] * priors[:, 2:],
File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/torch/tensor.py", line 283, in __mul__
return self.mul(other)
TypeError: mul received an invalid combination of arguments - got (torch.FloatTensor), but expected one of:
Try to put this snippet from train.py into your test.py file
if args.cuda and torch.cuda.is_available():
torch.set_default_tensor_type('torch.cuda.FloatTensor')
else:
torch.set_default_tensor_type('torch.FloatTensor')
Same issue.
It runs set_default_tensor_type to torch.cuda.FloatTensor.
Confirmed. Thank you for pointing that out. I've been "GPU-less" for a while, but I just gained access to a new one so I will add that tonight.
@mikejmills I just solved your issue without torch.set_default_tensor_type('torch.cuda.FloatTensor'). It comes from two tensors which are not converted to cuda tensor automatically. My fix is a bit hacky.
You should add this at the begging of the forward method: https://github.com/amdegroot/ssd.pytorch/blob/master/ssd.py#L68
if x.is_cuda:
self.priors = self.priors.cuda()
And this before self.output:
https://github.com/amdegroot/ssd.pytorch/blob/master/layers/functions/detection.py#L64
```python
if boxes.is_cuda:
ids = ids.cuda()
I feel like this wasn't an issue before, so it's weird that it came up now. All fixed though. Used .new() and .type_as() to try to make it a little less hacky.
Works great thank you for the help.
Most helpful comment
Try to put this snippet from train.py into your test.py file