I am trying to understand a deep learning model defined in torch7 framework here: code
I am new to deep learning and torch7 framework. I have tried reading the documentation of nn graph
module of torch, however, I don't understand what this line represents:
local e1 = - nn.SpatialConvolution(input_nc, ngf, 4, 4, 2, 2, 1, 1)
What is happening with = -
?
The torch tutorials which I've seen define a model using a simple straight-forward way:
...
model = nn.Sequential()
model:add(...)
...
However, the code I'm referring to, uses = -
and -
operations which I don't understand; neither I can find any tutorial which defines a model in this manner. Please help me to understand the code.
This is an alternative syntax to write models using the nngraph
package. You have basically two possibilities, either using the __call__
operator (()
) or using the __unm__
(unary multiplication, placing a -
sign before an expression) and the __sub__
(binary subtraction -
) to make "your code looks like a data flow".
Have a look at the documentation of the nngraph
package, this could help you understanding the syntax: https://github.com/torch/nngraph#two-hidden-layers-mlp