remaining = (FLAGS.EPOCH * dataset.train_batch_num - step) * FLAGS.BATCH_SIZE / rate print( "###################################################") print( "progress epoch %d step %d / %d image/sec %0.1f remaining %0.1fm" % (epoch, num, dataset.train_batch_num, rate, remaining / 60)) print("- Loss =", loss) print("- Weighted RMSE on validation =", valid_eval) print( "- Accuracy on validation =", np.sum(valid_y == valid_predict) / np.shape(valid_y)[0]) print("- Best(but not saved) Weight RMSE on validation =", saved_eval) print("- Best model on validation at epoch =", saved_epoch, "step =", saved_num) print("- Min kp-index on validation set :", np.min(valid_predict)) print("- Max kp-index on validation set :", np.max(valid_predict)) print("Finish!") if __name__ == '__main__': FLAGS = Config() FLAGS.MODE = 'train' main(FLAGS)
# Define label and model output. outputs = model.get_outputs() last_output = outputs[-1] output = tf.nn.softmax(last_output) output_class = tf.argmax(output, 1) tf_config = tf.ConfigProto(allow_soft_placement=True) tf_config.gpu_options.allow_growth = True with tf.Session(config=tf_config) as sess: saver = tf.train.Saver() saver.restore(sess, tf.train.latest_checkpoint(FLAGS.MODEL_PATH)) test_x = testset.X_test test_predict = sess.run(output_class, feed_dict={model._inputs: test_x}) f = open('output.csv', 'w', encoding='utf-8') wr = csv.writer(f) for date in np.arange(365): row_list = test_predict[date * 8:(date + 1) * 8] wr.writerow(row_list) f.close() print("Finished!") if __name__ == '__main__': FLAGS = Config() FLAGS.MODE = 'test' main(FLAGS)