Trying to train MatchNet but getting issues output loss calculation.
mukunda11 opened this issue · comments
I see that someone else had this issue before. Unfortunately, I will not be able to redownload pytorch with pip because I do not have sudo access to the server. I hope there is another way to solve the problem.
So, the error you're getting is
File "/depot/chubykin/gpu/pytorch-CortexNet-master/model/Model02.py", line 76, in forward
s = state[layer - 1] or V(x.data.clone().zero_())
torch.typename(self.data) + " is ambiguous")
RuntimeError: bool value of Variable objects containing non-empty torch.cuda.FloatTensor is ambiguous
where it used to be legal to check if an object
was not None
.
Now you have to rewrite
s = state[layer - 1] or V(x.data.clone().zero_())
as
s = state[layer - 1] if state[layer - 1] is not None else V(x.data.clone().zero_())
This should solve your issue.
If it does, you're more then welcome to send a PR fixing this and similar deprecated syntaxes.
If my reply fixes your problem, you can close this issue.
Please, don't upload pictures... Just type code and enclose it in three back-ticks ```. You can add the language too by typing python
after the ticks.
Anyhow, yes, replace if not h
with if h is None
.
Also, if you installed the latest PyTorch (version 0.4.0
), then return V(h.data)
should be replaced by return h.detach()
.
Apologies for the picture. Thank you for the quick response.