torch - Torch7, how to calculate the number of parameters in a convNet -
i looking way calculate number of parameters in convolutional neural network. in particular, using resnet model in https://github.com/facebook/fb.resnet.torch. know if there function calculate total number of parameters? have other suggestion doing it? in advance.
you have go through each layer of network , count number of parameters in layer. here sample function that:
-- example model fed function model = nn.sequential() model:add(nn.spatialconvolution(3,12,1,1)) model:add(nn.linear(2,3)) model:add(nn.relu()) function countparameters(model) local n_parameters = 0 i=1, model:size() local params = model:get(i):parameters() if params local weights = params[1] local biases = params[2] n_parameters = n_parameters + weights:nelement() + biases:nelement() end end return n_parameters end
Comments
Post a Comment