Training CNN error / CNN text classification

Going by the code in your gist, you aren’t actually creating a character based input, but lets get your model problem sorted out first.

What you are looking for is a reshape. In principle you shouldn’t need to add anything if your input type is set up correctly.

In that case it should add the conversion from CNN format to a flat format automatically:

And your original error message actually tells us that it is added.

So it looks like your actual problem is in data loading. And as I said initially, what you are doing certainly is not a character level one-hot encoding of the input.

As your data probably fits into memory comfortably, I suggest you start with using a CollectionSequenceRecordReader, and give it a <List<List<List<StringWritable>>>. The outer most list contains all of your examples. The middle list contains all the steps of your sequence. The inner most list is then a list of two elements new StringWritable(char) and new StringWritable(label).

While this does duplicate your label for every character, it simplifies the setup a bit. Once you understand how things work you can split that out again.

You then create a transform, that will turn your characters into a one hot encoding (e.g. see Quickstart with Deeplearning4J – dubs·tech) and create a SequenceRecordReaderDataSetIterator that will then create sequences of one hot encoded vectors, just as you wanted it to.

If you want to skip all that, and just have a sanity check that your model is correct first, you can simply create INDArrays of the correct shape (which you should understand by know) for your inputs and labels, and send it through the model (model.fit(input, labels)).