Freeze final layer


(Ashwin) #1

I am trying to train layer by layer. In a stage I would like to freeze the final layer alone . When i tried to freeze it I encounter an error saying . How do i solve this problem ? any idea ?

  RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn


(Kelam Goutam) #2

I guess you need to set requires_grad = False in the final layer.
I refereed this - RuntimeError: element 0 of variables does not require grad and does not have a grad_fn when trying to implement Gumbel-ST sampler
Do let me know if it works.


(Ashwin) #3

Works for me. Thanks.


(Kelam Goutam) #4

Happy to learn through you.