Open santhoshdc1590 opened 6 years ago
Thanks to this article Some important Pytorch tasks - A concise summary from a vision researcher
My code for freezing the layers in not exactly correct.
I was able to get the layers using this
OUTOUT
now to just freeze the vgg layer
OUTPUT
When the optimizer has to update the weights( by default requires_grad=True
while using optimiser I guess)
So on using this
we get an error
just change the net.parameters()
to filter(lambda p: p.requires_grad,net.parameters())
I wanted to freeze the first two layers of the network. Based on this I wrote a code to freeze the first two layers like this before the optimisation line 105 on train.py
Here's the code
I'm getting this error on this line
optimizer = optim.SGD(net.parameters(), lr=args.lr,momentum=args.momentum, weight_decay=args.weight_decay)
What's wrong any help would be appreciated. I'm stuck