0

I've tried to write a neural network but the accuracy doesn't change each epoch. I'm using keras and I can watch the accuracy change as each epoch is evaluated per se and it will start low, go up a bit, then drop back down to the exact same value each time example output. I've tried changing the batch size, learning rates, changing the data around a bit, but every time it does the same thing, just perhaps with a different accuracy value. I've also tried different optimizers. Any help is appreciated. (Also I was able to get an mnist example working)

model = Sequential()
model.add(Dense(1000, input_dim=100, init='uniform', activation='relu'))
model.add(Dense(len(history), init='uniform', activation='relu'))
model.add(Dense(1, init='uniform', activation='sigmoid'))
opt = SGD(lr=1, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='binary_crossentropy', optimizer=opt, metrics=['accuracy'])
model.fit(X, Y, nb_epoch=100, batch_size=50, verbose = 1)
scores = model.evaluate(X, Y)
print("%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))

1 Answers1

0

Since you only have a single neuron in your output layer, I assume you're doing regression and not classification.

If that's the case, then you should change your loss function to 'mse' and you also should remove the activation in your output layer because the sigmoid function will squash your output between 0 and 1.

Merwann Selmani
  • 1,066
  • 8
  • 7