apex icon indicating copy to clipboard operation
apex copied to clipboard

Runtime error of PRelu

Open xyzacademic opened this issue 7 years ago • 2 comments

When I use nn.PReLU(num_parameters=1, init=0.25), it gives me an error

return torch.prelu(input, weight) RuntimeError: expected scalar type Half but found Float

My apex setting is
with self.amp_handle.scale_loss(loss, self.optimizer) as scaled_loss: scaled_loss.backward() I tried to set weight.type_as(input), but it does not work. Is anybody can help me to fix this problem? I am very appreciate that.

xyzacademic avatar Mar 28 '19 18:03 xyzacademic

It looks like you're using the deprecated API. You should move to the new API as soon as possible, and be sure to call amp.initialize() on your model and optimizer before attempting to call with amp.scale_loss... https://nvidia.github.io/apex/amp.html https://nvidia.github.io/apex/amp.html#transition-guide-for-old-api-users This may resolve your issue.

mcarilli avatar Mar 28 '19 18:03 mcarilli

It looks like you're using the deprecated API. You should move to the new API as soon as possible, and be sure to call amp.initialize() on your model and optimizer before attempting to call with amp.scale_loss... https://nvidia.github.io/apex/amp.html https://nvidia.github.io/apex/amp.html#transition-guide-for-old-api-users This may resolve your issue.

Yes, it helps. I reinstall apex and it works. Thank you.

xyzacademic avatar Mar 28 '19 20:03 xyzacademic