I am following this lesson (section 6: How to relate all this) to my own dataset. I can get an example from the tutorial, without any problems with the provided sample dataset.
I get a binary cross-entropy error that is negative, and no improvement as ages evolve. I am pretty sure binary cross-entropy should always be positive, and I should see some improvement in loss. I shortened the output example (and code call) below to 5 eras. Others seem to encounter similar problems sometimes when learning CNN, but I did not see a clear solution in my case. Does anyone know why this is happening?
Output Example:
Creating TensorFlow device (/gpu:2) -> (device: 2, name: GeForce GTX TITAN Black, pci bus id: 0000:84:00.0)
10240/10240 [
Epoch 2/5
10240/10240 [
Epoch 3/5
10240/10240 [
Epoch 4/5
10240/10240 [
Epoch 5/5
10240/10240 [
My code is:
import numpy as np
import keras
from keras.models import Sequential
from keras.layers import Dense
from keras.callbacks import History
history = History()
seed = 7
np.random.seed(seed)
dataset = np.loadtxt('train_rows.csv', delimiter=",")
X = dataset[:, 0:(dataset.shape[1]-2)]
Y = dataset[:, dataset.shape[1]-1]
testset = np.loadtxt('test_rows.csv', delimiter=",")
X_test = testset[:,0:(testset.shape[1]-2)]
Y_test = testset[:,testset.shape[1]-1]
num_units_per_layer = [100, 50]
model = Sequential()
model.add(Dense(100, input_dim=(dataset.shape[1]-2), init='uniform', activation='relu'))
model.add(Dense(50, init='uniform', activation='relu'))
model.add(Dense(1, init='uniform', activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(X, Y, validation_data=(X_test, Y_test), nb_epoch=5, batch_size=128)