title: TypeError: rank mismatch between coding and true distributions
body: <p>I'm trying to adapt <a href="http://lasagne.readthedocs.org/en/latest/user/tutorial.html#run-the-mnist-example" rel="nofollow">Lasagne tutorial</a> to an LSTM model. This is how my code is atm:</p>
  
  <pre><code>def build_lstm(input_var=None):
      num_inputs, num_units, num_classes = 4978, 300, 127
      l_inp = lasagne.layers.InputLayer((None, None, num_inputs))
      batchsize, seqlen, _ = l_inp.input_var.shape
      l_lstm = lasagne.layers.LSTMLayer(l_inp, num_units=num_units)
      l_shp = lasagne.layers.ReshapeLayer(l_lstm, (-1, num_units))
      l_dense = lasagne.layers.DenseLayer(l_shp, num_units=num_classes)
      l_out = lasagne.layers.ReshapeLayer(l_dense, (batchsize, seqlen, num_classes))
  
      return l_out
  
  train_in, test_in, train_out, test_out = build_dataset()
  
  input_var = T.tensor4('inputs')
  target_var = T.ivector('targets')
  
  myLSTMNetwork = build_lstm()
  
  #Loss evaluation
  prediction = lasagne.layers.get_output(myLSTMNetwork)
  loss = lasagne.objectives.categorical_crossentropy(prediction, target_var)
  loss = loss.mean()
  </code></pre>
  
  <p>I can build my model without errors. But after inserting the code related to Loss evaluation I get this error:</p>
  
  <pre><code>File "code.py", line 110, in build_lstm
      loss = lasagne.objectives.categorical_crossentropy(prediction, target_var)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lasagne/objectives.py", line 146, in categorical_crossentropy
      return theano.tensor.nnet.categorical_crossentropy(predictions, targets)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/theano/tensor/nnet/nnet.py", line 1906, in categorical_crossentropy
      raise TypeError('rank mismatch between coding and true distributions')
  TypeError: rank mismatch between coding and true distributions
  </code></pre>