Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mini-batch in forward computing? #15

Open
cyxtj opened this issue Sep 28, 2017 · 0 comments
Open

mini-batch in forward computing? #15

cyxtj opened this issue Sep 28, 2017 · 0 comments

Comments

@cyxtj
Copy link

cyxtj commented Sep 28, 2017

I'm focusing on Tree-LSTM. My question is:

  1. can torch implement of treeLSTM do mini-batching during forward pass?
  2. And if not, has anyone see any mini-batch implementation of treeLSTM in Theano/tensorflow/pytorch/mxnet/dynet/tf-fold... or any other framework, or even C++?
  3. for the framework like torch that is "dynamic", will mini-batch speedup the computation?

I'm new to torch, but from the code in sentiment/TreeLSTMSentiment.lua

      local loss = 0
      for j = 1, batch_size do
        local idx = indices[i + j - 1]
        local sent = dataset.sents[idx]
        local tree = dataset.trees[idx]

        local inputs = self.emb:forward(sent)
        local _, tree_loss = self.treelstm:forward(tree, inputs)
        loss = loss + tree_loss
        local input_grad = self.treelstm:backward(tree, inputs, {zeros, zeros})
        self.emb:backward(sent, input_grad)

I think the forward and backward pass are computed one sample a time, and accumulate the gradient in a mini-batch before updating. So it is not a mini-batch forward computing, but a mini-batch update.

@kaishengtai Would you help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant