Skip to content

Instantly share code, notes, and snippets.

@jfsantos
Created December 30, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfsantos/0c3b19fb23ba680dbf3e to your computer and use it in GitHub Desktop.
Save jfsantos/0c3b19fb23ba680dbf3e to your computer and use it in GitHub Desktop.
Example of classifier using Torch and the rnn module
model = nn.Sequential()
lstm = nn.Sequencer(
nn.Sequential()
:add(nn.LSTM(nFeatures,nHidden))
:add(nn.Dropout())
:add(nn.LSTM(nHidden,nHidden))
)
lstm:remember('neither') -- force model to call forget at each call to forward
model:add(lstm)
model:add(nn.SelectTable(-1))
model:add(nn.Dropout())
model:add(nn.Linear(nHidden, nClasses))
model:add(nn.LogSoftMax())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment