I'm still new to keras and python, and I'm getting an error I can't seem to understand. The error is:
Traceback (most recent call last):
File "/Users/N/PycharmProjects/hw2/hw2_1.py", line 35, in <module>
model.fit(trainingInp, trainingOut, epochs=10, batch_size=1)
File "/Library/Python/2.7/site-packages/keras/models.py", line 893, in fit
initial_epoch=initial_epoch)
File "/Library/Python/2.7/site-packages/keras/engine/training.py", line 1555, in fit
batch_size=batch_size)
File "/Library/Python/2.7/site-packages/keras/engine/training.py", line 1409, in _standardize_user_data
exception_prefix='input')
File "/Library/Python/2.7/site-packages/keras/engine/training.py", line 126, in _standardize_input_data
array = arrays[i]
UnboundLocalError: local variable 'arrays' referenced before assignment
It happens in model.fit(). My model is like so:
model = Sequential()
model.add(Dense(3, activation='sigmoid', input_dim=8))
model.add(Dropout(0.5))
model.add(Dense(10, activation='sigmoid'))
model.compile(loss='mean_squared_error', optimizer='sgd', metrics=['accuracy'])
print trainingInp
print trainingOut
model.fit(trainingInp, trainingOut, epochs=10, batch_size=1)
I print my data to make sure I'm not passing empty data in, and it prints correctly just before going into model.fit().
I'm not quite sure how to fix it as I don't really know what the problem is. It seems like the problem is batch_size, but I thought a batch size of 1 is allowed.
Here is how I get my data. I am guaranteed that the data doesn't have any empty values.
#read and categorize data
data = pandas.read_csv('cars.data.txt', delim_whitespace=True, header=None)
#turn class into an integer
enc = pandas.factorize(data['class'])
data["enc"] = enc[0]
#split the data set and make class into a matrix of outputs
trainingSet, testingSet = train_test_split(data, test_size=0.3)
trainingInp = trainingSet.iloc[:,1:9]
trainingOut = keras.utils.to_categorical(trainingSet['enc'], num_classes=10)
testingInp = testingSet.iloc[:,1:9]
testingOut = keras.utils.to_categorical(testingSet['enc'], num_classes=10)