Thanks for writing back Adam.  So this is the “flexible input size” feature I’ve been hearing so much about. Great!
If I may ask a related question then:  if I actually wanted to try to start the generator code using a sequence that is 20 timesteps long, using data from the “test” dataset as in the two attempts I listed above, how would you make it so that “model” would accept that input?
I tried converting “input” to a variable (in generate.py)…
eval_batch_size = 10
test_data = batchify(corpus.test, eval_batch_size)

def get_batch(source, i, evaluation=False):
    bptt = 20
    seq_len = min(bptt, len(source) - 1 - i)
    data = Variable(source[i:i+seq_len], volatile=evaluation)
    target = Variable(source[i+1:i+1+seq_len].view(-1))
    return data, target

input, target = get_batch(test_data, 0, evaluation=True)
#input = Variable(torch.rand(1, 1).mul(ntokens).long(), volatile=True)

input = Variable(input, volatile=True)

…but when I do that, I get the error that it’s already a Variable (presumably because of the cast in batchify):

Traceback (most recent call last):
File “generate.py”, line 83, in 
input = Variable(input, volatile=True)
RuntimeError: Variable data has to be a tensor, but got Variable

But if it’s already a Variable, then I don’t understand why I can’t use it as an input to “model” further below.   (?)
Because if I don’t include that extra “Variable” re-casting, then still I get “inconsistent tensor size”…

Traceback (most recent call last):
File “generate.py”, line 90, in 
output, hidden = model(input, hidden)
File “/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py”, line 210, in call
result = self.forward(*input, **kwargs)
File “/home/mcskwayrd/neural/torch/pytorch/examples/word_language_model/model.py”, line 28, in forward
output, hidden = self.rnn(emb, hidden)
File “/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py”, line 210, in call
result = self.forward(*input, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/torch/nn/modules/rnn.py”, line 79, in forward
return func(input, self.all_weights, hx)
File “/usr/local/lib/python2.7/dist-packages/torch/nn/_functions/rnn.py”, line 228, in forward
return func(input, *fargs, **fkwargs)
File “/usr/local/lib/python2.7/dist-packages/torch/nn/_functions/rnn.py”, line 138, in forward
nexth, output = func(input, hidden, weight)
File “/usr/local/lib/python2.7/dist-packages/torch/nn/_functions/rnn.py”, line 67, in forward
hy, output = inner(input, hidden[l], weight[l])
File “/usr/local/lib/python2.7/dist-packages/torch/nn/_functions/rnn.py”, line 96, in forward
hidden = inner(input[i], hidden, *weight)
File “/usr/local/lib/python2.7/dist-packages/torch/nn/_functions/rnn.py”, line 22, in LSTMCell
gates = F.linear(input, w_ih, b_ih) + F.linear(hx, w_hh, b_hh)
File “/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py”, line 748, in add
return self.add(other)
File “/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py”, line 288, in add
return self._add(other, False)
File “/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py”, line 282, in _add
return Add(inplace)(self, other)
File “/usr/local/lib/python2.7/dist-packages/torch/autograd/_functions/basic_ops.py”, line 13, in forward
return a.add(b)
RuntimeError: inconsistent tensor size at /home/soumith/local/builder/wheel/pytorch-src/torch/lib/TH/generic/THTensorMath.c:601

What is the source of this inconsistency, if the input length isn’t supposed to matter?