简体   繁体   中英

Tensorflow Regression is predicting insanely wrong values

I am currently doing an exercise for university. The task is to change a given classification to regression. I did all the changes to the data's preprocessing and the network, so the regression is executed.

But when I try to test the network's prediction, there are insanely wrong values predicted.

The data is a pixel matrix and a corresponding angle between 0° and 90°. I have splitted up the data to a training set and a testing set and checked all the values in both sets are in range 0° to 90°.

To test the accuracy of the regression I run the following code:

def reg_perceptron(t, weights, biases):
    t = tf.nn.relu(tf.add(tf.matmul(t, weights['h1']), biases['b1']), name = "layer_1")
    t = tf.add(tf.matmul(t, weights['hOut'], name="LOut_MatMul"), biases['bOut'], name = output_tensor)
    return t

pred = reg_perceptron(_x, rg_weights, rg_biases)


pred_y = np.array([])
total_batch_test = int(len(test_x)/batch_size)
for i in range(total_batch_test):
    lower_bound = i * batch_size
    upper_bound = i * batch_size + batch_size
    batch_test_x = test_x[lower_bound : upper_bound]#test_x are the pixel matrices of the test dataset
    feed_dict = {_x: batch_test_x}
    batch_test_y_predict = sess.run(pred, feed_dict = feed_dict)
    print ("min: %.2f max: %.2f" % (batch_test_y_predict.min(), batch_test_y_predict.max()))
    #WHY ARE THERE VALUES LIKE min: -13563819760524520849408.00 max: 1280719166070321053696.00 PREDICTED?

    if len(pred_y) == 0:
        pred_y = batch_test_y_predict
    else:
        pred_y = np.concatenate((pred_y, batch_test_y_predict), axis=0)

# Print test results.
pred_y = pd.Series(pred_y.reshape(-1).tolist())
#cut of the last elements if division by batch_size has rest
true_y = test_y[:pred_y.size]

RMSE = np.sqrt(np.mean(np.square(np.subtract(pred_y, true_y))))
print ("Epoch: %3.i - RMSE: %.2f" % (epoch, RMSE))

Why are there values in range min: -13563819760524520849408.00 max: 1280719166070321053696.00 predicted, if the training data was only in range 0° to 90°?

Thus I get the result: Epoch: 0 - RMSE: 23738450191911909064704.00, which obviously should be way under 90°.

我可以通过规范化给定数据来解决问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM