This is NOT MY code by here is the line, where it shows a problem:
model.fit(trainX, trainY, batch_size=2, epochs=200, verbose=2)
(As I am thinking now, it i
I checked in the training_arrays.py
(here) the function in which you got the error and, as I can see, I think the problem could be in these statements (from lines 177 - 205):
batches = make_batches(num_train_samples, batch_size)
for batch_index, (batch_start, batch_end) in enumerate(batches): # the problem is here
# do stuff
...
if batch_index == len(batches) - 1:
# do stuff
...
If batches is an empty list, you could get this error. Could be that your training set has some problem?
UnboundLocalError: local variable 'batch_index' referenced before assignment
The reason for the problem is that the list of batches is empty! batches ==[]
The reason it is blank is because the number of samples for training data is too small to be divided by batch_size
You should check your data, number of samples or You should reduce batch_size to a point that allows you to divide the number of samples by batch size with a real result..
I had to import the correct libraries (Tensorflow and not Keras directly):
from tensorflow.python import keras.models.Sequential
from tensorflow.python import keras.layers.Dense
from tensorflow.python.keras.layers import Input, Dense
from tensorflow.python.keras.models import Sequential
Apparently this is related to the different version issue of Keras.
This error is because there is empty training data. whether you import from keras directly or from tensorflow there will be error if you not pass proper data, error message might be different as per import or version. Also make sure your are passing couple of records in data. If you import Keras from tensorflow and use the the error will be
"raise ValueError('Empty training data.') ValueError: Empty training data."
If directly then the message will be the error message given in question.