You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to implement my own cost function to train my model a multi-layer perceptron, my concern is that during training I receive the following problem :
Check failed: !AGInfo::IsNone(*i): Cannot differentiate node because it is not in a computational graph. You need to set is_recording to true or use autograd.record() to save computational graphs for backward. If you want to differentiate the same graph twice, you need to pass retain_graph=True to backward.
i tried :
def myloss(forecast, target):
.
.
.
.
with autograd.record():
loss= nd.array(np.sqrt((r-1)**2+(beta-1)**2+(gamma-1)**2))
return loss
and in hybrid_forward i call my lost function
def hybrid_forward(self, F, past_target, future_target):
prediction = self.nn(past_target)
loss = ( 1 - self.myloss( prediction,future_target) ).mean(axis=-1)
return loss
I also noticed that when I calculate a loss without converting my parameters from mxnet ndarray to numpy ndarray it works, but in my case it is mandatory since I have to perform several intermediate calculations.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I am trying to implement my own cost function to train my model a multi-layer perceptron, my concern is that during training I receive the following problem :
i tried :
and in
hybrid_forward
i call my lost functionI also noticed that when I calculate a loss without converting my parameters from mxnet ndarray to numpy ndarray it works, but in my case it is mandatory since I have to perform several intermediate calculations.
Beta Was this translation helpful? Give feedback.
All reactions