Getting high training accuracy, but incorrect predictions for the training set
I am trying to get predictions for a set of workouts but I always get the same result for each image. Can anyone help me please?
This is how I defined the network:
x = tf.placeholder(tf.float32, shape=[None, image_size_h, image_size_v, num_channels])
y_ = tf.placeholder(tf.float32, shape=[None, num_classes])
keep_prob = tf.placeholder(tf.float32)
def conv_net(x1, weights, biases):
# First Convolution Layer
conv1 = conv2d_pool(x1, weights['wc1'], biases['bc1'], 'conv1')
#print(conv1.get_shape())
# Second Convolution Layer
conv2 = conv2d(conv1, weights['wc2'], biases['bc2'], 'conv2')
conv3 = conv2d(conv2, weights['wc3'], biases['bc3'], 'conv3')
conv4 = conv2d(conv3, weights['wc4'], biases['bc4'],'conv4')
conv5 = conv2d(conv4, weights['wc5'], biases['bc5'],'conv5')
conv6 = conv2d(conv5, weights['wc6'], biases['bc6'],'conv6')
# Fully connected layer
fc1 = fullycon(conv6, weights['wd1'], biases['bd1'], 'fc1')
# Dropout
fc1_drop = tf.nn.dropout(fc1, keep_prob)
fc2 = fullytanh(fc1_drop, weights['wd2'], biases['bd2'], 'fc2')
out = tf.add(tf.matmul(fc2, weights['out']), biases['bout'])
return out
pred = conv_net(x, weights, biases)
prediyo = tf.argmax(tf.nn.softmax(pred), axis=1)
# Loss and optimizer
correct_prediction = tf.equal(tf.argmax(y_,axis=1), tf.argmax(pred,axis=1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
optimizer = tf.train.AdamOptimizer(learning_rate=lr).minimize(cost)
So far I am getting the forecast by doing:
result_boxes_n = normalise_images(result_boxes)
for n in range (0,result_boxes.shape[0]):
predicted = prediyo.eval(feed_dict={x:np.reshape(result_boxes_n[n,:,:,:],(1,9,8,3)), keep_prob: 1})
print(predicted)
the predicted outputs are always of the same class, although the training accuracy is higher than 90%. However, if I do this:
prediyo.eval(feed_dict={x:result_boxes_n, keep_prob: 1})
it works, but not when I try to make individual predictions.
Thank you in advance
+3
source to share
No one has answered this question yet
Check out similar questions: