Testing the TensorFlow RNN model

To see whether the loss value after 500 epochs is good enough, let's add the following code using the testing dataset to calculate the number of correct predictions among the total testing examples (by correct, we mean the predicted price goes up or down in the same direction as the target price, relative to the price of the previous day):

    correct = 0    y_pred = sess.run(outputs, feed_dict={X: X_test})     targets = []    predictions = []    for i in range(y_pred.shape[0]):        input = X_test[i]        target = y_test[i]        prediction = y_pred[i]        targets.append(target[-1][0])        predictions.append(prediction[-1][0])        if target[-1][0] >= input[-1][0] and prediction[-1][0] >=         input[-1][0]:            correct += 1 elif target[-1][0] < input[-1][0] ...

Get Intelligent Mobile Projects with TensorFlow now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.