Hello, can some figure out this error?
thanks
TypeError Traceback (most recent call last)
in
—> 44 qx = k * qx
45 Div = Divergence( x_trg , qx )
46 ########################################################
TypeError: unsupported operand type(s) for *: ‘Tensor’ and ‘NoneType’
for qx is defined as: qx = Gradient( x_trg , T )
Based on the error message it seems that qx
is None
. Could you check, if Gradient
is returning a value or if the return
statement is either not used or is returning None
?
1 Like
Yeak I chesked, gradient returns None, and I don’t know how to make it returning value.
gradient function is defined with:
torch.autograd.grad (outputs , inputs , grad_outputs=None , retain_graph=None , create_graph=False , only_inputs=True ):
torch.autograd.grad
should yield the desired gradients, so maybe you are missing to assign them to a return value?
1 Like
thanks for replying, here is gradient function:
I’m not sure why a None
value is returned. Could you post a minimal code snippet to reproduce this issue, i.e. valid gradients are expected while you are seeing None
s?
Actually the model is composed of several files ( it’s physics-informed neural network), I send you in message the portion of the code that precedes the calling of gradient.
Could you please post the code here, as you shouldn’t share private code with anyone who is not collaborating on your project?
yeah, I can’t share it here, it’s private code 
That’s understandable. Could you come up with a minimal “fake” example, which would reproduce the issue you are seeing, but wouldn’t show anything from your architecture etc.?
1 Like