title: Deeplearning4j: LSTM example for review sentiment analysis
body: <p>I am looking through the example of deeplearning 4j for classifying movie reviews according to their sentiment. 
  <a href="https://github.com/deeplearning4j/dl4j-0.4-examples/blob/master/src/main/java/org/deeplearning4j/examples/recurrent/word2vecsentiment/SentimentExampleIterator.java)" rel="nofollow">ReviewExample</a> </p>
  
  <p>At line 124-142 the N-dimensional arrays are created and I am kind of unsure what is happening at these lines:</p>
  
  <p>Line 132: </p>
  
  <pre><code>features.put(new INDArrayIndex[]{NDArrayIndex.point(i),
  NDArrayIndex.all(), NDArrayIndex.point(j)}, vector);
  </code></pre>
  
  <p>I can image that <code>.point(x)</code> and <code>.point(j)</code> address the cell in the array, but what exactly does the <code>NDArrayIndex.all()</code> call do here? </p>
  
  <p>While building the feature array is more or less ok what is happening there I get totally confused by the label mask and this <code>lastIdx</code> variable</p>
  
  <p>Line 138 - 142</p>
  
  <pre><code>            int idx = (positive[i] ? 0 : 1);
              int lastIdx = Math.min(tokens.size(),maxLength);
              labels.putScalar(new int[]{i,idx,lastIdx-1},1.0);   //Set label: [0,1] for negative, [1,0] for positive
              labelsMask.putScalar(new int[]{i,lastIdx-1},1.0);   //Specify that an output exists at the final time step for this example
  </code></pre>
  
  <p>The label array itself is addressed by <code>i, idx</code> e.g. column/row that is set to 1.0 - but I don't really get how this time-step information fits in? Is this conventional that the last parameter has to mark the last entry?</p>
  
  <p>Then why does the labelsMask use only <code>i</code> and not <code>i, idx</code> ? </p>
  
  <p>Thanks for explanations or pointer that help to clarify some of my questions</p>