LiJunnan1992 / MLNT

Meta-Learning based Noise-Tolerant Training
123 stars 29 forks source link

Can't detach views in-place. #8

Open Oasis1307 opened 4 years ago

Oasis1307 commented 4 years ago

RuntimeError: Can't detach views in-place. Use detach() instead I have no idea why it can't detach views in-place. Any way to get around this problem? thanks!

pytorch 1.3.1

LiJunnan1992 commented 4 years ago

Can you try tensor = tensor.detach()?

Oasis1307 commented 4 years ago

If using this tensor to compute weights, the first noise type iteration is ok. But the second noise type it cannot compute grads = torch.autograd.grad()

RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.

which pytorch version do you use, please?

chiragbajaj25 commented 4 years ago

Try consistent_loss.backward(retain_graph=True)

Wongcheukwai commented 4 years ago

have you solved the problem yet? I tried everything.

136002320 commented 1 year ago

eg: hidden[0].detach() hidden[1].detach() => hidden.detach_()

That's all right