Example #1
0
cost_hist_train, cost_hist_test, value_hist_train, value_hist_test, value_hist_cv, value_hist_train_ma, \
    value_hist_test_ma, value_hist_cv_ma, step, step_hist, saving_score = [
    ], [], [], [], [], [], [], [], 0, [], 0.05
saver = tf.train.Saver()
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)

# main loop
while True:

    if step == 2000:
        break

    # train model
    x_train, y_train = get_data_batch(
        [input_train, output_train], batch_size, sequential=False)
    _, cost_train = sess.run([train_step, cost],
                             feed_dict={x: x_train, y: y_train, learning_r: learning_rate, drop_out: drop_keep_prob})

    # keep track of stuff
    step += 1
    if step % 1 == 0 or step == 1:

        # get y_ predictions
        y_train_pred = sess.run(
            y_, feed_dict={x: input_train, drop_out: drop_keep_prob})
        y_test_pred, cost_test = sess.run(
            [y_, cost], feed_dict={x: input_test, y: output_test, drop_out: drop_keep_prob})
        y_cv_pred = sess.run(
            y_, feed_dict={x: input_cv, drop_out: drop_keep_prob})
Example #2
0
    value_hist_test_ma, value_hist_cv_ma, step, step_hist, saving_score = [
    ], [], [], [], [], [], [], [], 0, [], 0.05
saver = tf.train.Saver()
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)

# train
while True:

    if step == 30000:
        break

    # train model
    x_train, price_batch = get_data_batch([input_train[:-1], price_train[1:]],
                                          batch_size,
                                          sequential=False)
    _, cost_train = sess.run(
        [train_step, cost],
        feed_dict={
            x: x_train,
            price_h: price_batch,
            learning_r: learning_rate,
            drop_out: drop_keep_prob
        })

    # keep track of stuff
    step += 1
    if step % 100 == 0 or step == 1:

        # get y_ predictions