Illegal State Exception 3D input expected to RNN layer expected, got 2

I am attempting to run a LSTM neural network to classify time-series data from an IMU as either a correct or incorrect motion. The error is saying that the input is 2D but it needs to be 3D. Is there a method or way of forcing the input to be 3D without manually editing the input before loading it into the neural network? My features and labels are in one file and I want to read the last column as the labels while the first 3 columns are used as features. This is how I am loading the input data.

DataSet trainData;
SequenceRecordReader trainFEATURES = new CSVSequenceRecordReader(0, “;”);
trainFEATURES.initialize(new NumberedFileInputSplit(trnValue, 2, 2));
SequenceRecordReaderDataSetIterator trainIter = new SequenceRecordReaderDataSetIterator(trainFEATURES, miniBatchSize1, numLabels,labelIndex, false);
trainIter.setPreProcessor(new LabelLastTimeStepPreProcessor());
trainData =;

//Loading the test data
DataSet testData;
SequenceRecordReader testFEATURES = new CSVSequenceRecordReader(0, “;”);
testFEATURES.initialize(new NumberedFileInputSplit(tstValue, 2, 2));
SequenceRecordReaderDataSetIterator testIter = new SequenceRecordReaderDataSetIterator(testFEATURES, miniBatchSize2, numLabels, labelIndex, false);
testIter.setPreProcessor(new LabelLastTimeStepPreProcessor());
testData =;

and this is how I have setup my neural network layers.

.layer(0, new LastTimeStep (new LSTM.Builder().nIn(numInputs).nOut(numHiddenNodes).activation( Activation . TANH ).weightInit( WeightInit . RELU ).build()))

.layer(1, new LastTimeStep(new LSTM.Builder().nIn(numHiddenNodes).nOut(numHiddenNodes).activation( Activation . TANH ).weightInit( WeightInit . RELU ).build()))

.layer(2, new RnnOutputLayer.Builder(LossFunctions. LossFunction . MCXENT ).nIn(numHiddenNodes).nOut(numOutputs).activation( Activation . SOFTMAX ).weightInit( WeightInit . XAVIER ).build()).build();

@MaverickDeuce what version are you using? Do you have the complete code we can look at?

The model version is 4.0.0 and the master version is 1.0.0-M1.1.
The error occurs at line 107 when I run the .fit() method.

This is the link to the complete code on github:

I wanted to share this updated error so that it may be easier to help find a solution.

Sequence lengths do not match for RnnOutputLayer input and labels:Arrays should be rank 3 with shape [minibatch, size, sequenceLength] - mismatch on dimension 2 (sequence length) - input=[2, 2, 1] vs. label=[2, 2, 1290]

I am confused because I at first thought the program was confusing my features for labels and vice versa as the first feature file contains 1290 sequence length while the label has a sequence length of 1. But as I modified the data while testing my hypothesis I found that the error prints the sequence length of the file with the largest sequence length when evaluating both the features and labels. I am now trying to figure out what the error is considering as input? If both features and labels are being represented by the label in the above error. Also why must the sequences lengths be the same in the first place?

This is the link to the github repository: GitHub - jivilearning/JIBandMedic
The code is under DLTestClass. The Data for training and testing is under the training data and testing data repository. The label information is under the corresponding directories for training labels and testing labels.