NOTE: This is only a partial answer, which resolves only the exception. However the C# code in the OP, even corrected based on this partial answer still has some inherent problem: It converges the NN to produce 0, 0, 0, 0 output (instead of the expected XOR rule 0, 1, 1, 0). I am posting this in hope it helps to iterate to the correct answer.
Maybe I am missing something, but my translation uses the batch size 4, while the original Python version somehow infers it being the training data in shape[2,4]
Anyway this causes the extra parameter batch_size
with value 4
in fit()
as I figured it out originally.
What I did not figured out, (and the resolution of the issue) is that this extra parameter batch_size
with value 4
must be provided to model.predict()
too, so instead the line
print(model.predict(trainingData));
we should have
print(model.predict(trainingData, 4));
If anyone knows how to be more faithful to the original Python in regard using the API please correct me.