Collection<Example> examples = input.first();
FeedforwardParams params = input.second();
// We can't fix the seed used with ThreadLocalRandom
// TODO: Is this a serious problem?
ThreadLocalRandom random = ThreadLocalRandom.current();
gradW1 = new double[W1.length][W1[0].length];
gradb1 = new double[b1.length];
gradW2 = new double[W2.length][W2[0].length];
gradE = new double[E.length][E[0].length];
double cost = 0.0;
double correct = 0.0;
for (Example ex : examples) {
List<Integer> feature = ex.getFeature();
List<Integer> label = ex.getLabel();
double[] scores = new double[numLabels];
double[] hidden = new double[config.hiddenSize];
double[] hidden3 = new double[config.hiddenSize];
// Run dropout: randomly drop some hidden-layer units. `ls`
// contains the indices of those units which are still active
int[] ls = IntStream.range(0, config.hiddenSize)
.filter(n -> random.nextDouble() > params.getDropOutProb())
.toArray();
int offset = 0;
for (int j = 0; j < config.numTokens; ++j) {
int tok = feature.get(j);