Fix some parameters and train others

65 views
Skip to first unread message

Pedro Porto Buarque de Gusmão

unread,
Oct 5, 2015, 10:49:57 AM10/5/15
to torch7
Hi,

Is there a way to keep some of the networks layers/parameters fixed and do training only on specific parameters?

Thanks

Pedro

Francisco Vitor Suzano Massa

unread,
Oct 5, 2015, 12:15:08 PM10/5/15
to torch7
For the modules you want to fix the layers, you can override the accGradParameters function with a void function.
For example, say you have a model like
model = nn.Sequential():add(nn.Linear(2,2)):add(nn.Linear(2,2))

you can fix the first layer by doing

model:get(1).accGradParameters = function() end

Now, if you want to have different learning rates per layer, look at the second post in https://gist.github.com/szagoruyko/1e994e713fce4a41773e

Pedro Porto Buarque de Gusmão

unread,
Oct 6, 2015, 10:12:57 AM10/6/15
to torch7
Thank you!
Reply all
Reply to author
Forward
0 new messages