I'm trying to educate myself on tensorflow. I decided to implement the infamous kaggle titanic challenge in tensorflow, without using tf.layers, tf.train, or keras. I'm using what's probably a comically oversized network. My problem is that I can't seem to get the accuracy calculation correct.
In my example, Y is the output of my final layer (width 1). Y_ is the label of that training example. So, when I compute accuracy, I compute it as:
Y_int = tf.cast(Y_, tf.int64)
is_correct = tf.equal(tf.argmax(Y,1),Y_int)
accuracy = tf.reduce_mean(tf.cast(is_correct,tf.float32))
I run it every 500 iterations: a,c = sess.run([accuracy,xe], feed_dict=test_data)
Cross entropy reduces "nicely" - there's lots of room for improvement, but it does change iteration to iteration. Accuracy, though, is stubbornly stuck (it's the first value):
iter: 0
0.606742 72.3839
iter: 500
0.606742 42.3199
iter: 1000
.....
iter: 18500
0.606742 38.2022
iter: 19000
0.606742 38.4258
iter: 19500
0.606742 37.9204
EDIT: the full python file: https://github.com/mrx80/so/blob/master/titanic_nn.py