Skip to content

Instantly share code, notes, and snippets.

@dean-shaff
Last active March 14, 2016 12:53
Show Gist options
  • Save dean-shaff/38096d9ffe95c89ec84d to your computer and use it in GitHub Desktop.
Save dean-shaff/38096d9ffe95c89ec84d to your computer and use it in GitHub Desktop.
Building and training a simple MLP in torch
-- building the MLP
net = nn.Sequential()
net:add(nn.Linear(150,400))
net:add(nn.Linear(400,300))
net:add(nn.Linear(300,200))
net:add(nn.Tanh()) -- tanh squashing function
net:add(nn.Linear(200,2))
net:add(nn.LogSoftMax())
-- Training the net
criterion = nn.ClassNLLCriterion()
trainer = nn.StochasticGradient(net, criterion)
trainer.learningRate = 0.01
trainer.maxIteration = 10
trainer:train(trainset)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment