-
Q: I run the installation commands from the website, type
th
and nothing happens
A: addtorch/install/bin/torch-activate
to your.bash_profile
-
Q: When I run
image.display(image.lena())
there is an error
A: Start torch withqlua
instead ofth
-
Q: I updated or tried to update
some package
and have build or runtime errors
A: Most probably another package is not up-to-date. Update the core packages by runningupdate.sh
or update torch/nn/cutorch/cunn in this order -
Q: I have build/runtime errors on OS X with cutorch/cunn like
malformed mach-o
orfailed to load lib*.dylib
A: Update cmake and CUDA to the latest version -
Q: How to set different learning rates/weight decays per layer
A: Two ways of doing it:
- if you are using optim.sgd, pass as argument to the optimState the fields learningRates/weightDecays, containing a Tensor with the multiplying factors (for the learning rate) or the values itself (for the weight decay) per parameter of the network. Here is an example. The downside of this approach is that you need to store an extra tensor of the size of the network.
- instead of doing parameters, gradParameters = model:getParameters(), do parameters, gradParameters = model:parameters(). This will give you a table of tensors, each one of them corresponding to a separate weight/bias per layer. While optimizing using optim, keep a separate optimState for each parameter (which implies calling optim.sgd in a for loop).
-
Q: How to convert a linear layer into a convolutional layer (e.g., to use my pre-trained network in a fully-convolutional manner) ?
A: Use this function https://gist.github.com/szagoruyko/4e0d2b7f5fdaf877a6a9 -
Q: I trained a network on GPU, can I use it on CPU?
A: Yes!net = net:float()
will copy it to CPU -
Q: I am trying to make a siamese network and do
net_b = net_a:share('weight','bias')
, but when I try to callnet:getParameters()
there is an error.
A: You need to sharegradWeight
andgradBias
too:net_b = net_a:share('weight','bias','gradWeight','gradBias')
-
Q: Is there multiGPU neural network training support in Torch?
A: Sure! see https://github.com/soumith/imagenet-multiGPU.torch -
Q: I want to implement my own neural network module, what should I do?
A: Check the docs http://torch.ch/docs/developer-docs.html -
Q: I am curious about the difference between
nn.SpatialConvolution
andnn.SpatialConvolutionMM
. Is it just a difference in the implementation or does it perform a different mathematical operation?
A: There is no difference betweennn.SpatialConvolution()
andnn.SpatialConvolutionMM()
. Both of them point to the MM implementation. -
Q: Is it possible to specify which GPU to be used?
A: Usecutorch.setDevice(gpuId)
or start torch withCUDA_VISIBLE_DEVICES=[gpuId-1] th
. The latter is a low level call which isolates specified GPUs from the others. -
Q: Is torch supported on Windows:
A: Not supported atm, although you can check this google question https://groups.google.com/forum/#!topic/torch7/IOB4aY6ClEA or check this repo https://github.com/diz-vara/luajit-rocks.
A: Two easy ways of doing it:
optim.sgd
, pass as argument to theoptimState
the fieldslearningRates
/weightDecays
, containing aTensor
with the multiplying factors (for the learning rate) or the values itself (for the weight decay) per parameter of the network. Here is an example. The downside of this approach is that you need to store an extra tensor of the size of the network.parameters, gradParameters = model:getParameters()
, doparameters, gradParameters = model:parameters()
. This will give you a table of tensors, each one of them corresponding to a separate weight/bias per layer. While optimizing usingoptim
, keep a separateoptimState
for each parameter (which implies callingoptim.sgd
in a for loop).A: See this link