Hello,
Imagine the following simple function that result depend on an optional arg
def fnt(a,b,c=None):
if c != None:
res = a+b+c
else:
res = a+b
return res
The point is that if cis set to a torch tensor as aand `b, then an exception is rised.
TypeError: ne() received an invalid combination of arguments - got (NoneType), but expected one of:
* (Tensor other)
didn't match because some of the arguments have invalid types: (NoneType)
* (Number other)
didn't match because some of the arguments have invalid types: (NoneType)
Do you know how to manage the possibility to get c as option?
(nb. I have swap the if condition according to @Deepali suggestion even if the problem remains)
Sorry,
The fnt I consider in the example is simple and you’re right in the philosophy.
But it remains that the c != None cannot apply. c is a torch.tensor of shape (N,1) where N is the batch size.
a= torch.Size([100, 1])
if a != None:
print(a)
else:
print('nok')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: ne() received an invalid combination of arguments - got (NoneType), but expected one of:
* (Tensor other)
didn't match because some of the arguments have invalid types: (NoneType)
* (Number other)
didn't match because some of the arguments have invalid types: (NoneType)