-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.py
29 lines (25 loc) · 914 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import numpy as np
import tensorflow as tf
from tensorflow_prediction import forex_data, model as build_model
pred_length = 1
train_x, test_x, train_y, test_y = forex_data.gen_data("EURUSD", forex_data.m1_args, pred_length)
#pattern 1
model = build_model.build_model(build_model.dense_net, (120, 1), pred_length)
#pattern 2
model = build_model.dense_model
model_opt = model.init_conv_option
model.init_conv_option(128, (3, 6, 3))
mdoel = model.build_model((120, 1), pred_length)
opt = tf.keras.optimizers.Adam(1e-3)
model.compile(opt, "mse", ["mae"])
train_callbacks = [
tf.keras.callbacks.EarlyStopping(
monitor="val_loss", patience=10,
restore_best_weights=True
),
tf.keras.callbacks.ReduceLROnPlateau(
monitor="val_loss", factor=0.5,
patience=2, verbose=1
)
]
model.fit(train_x, train_y, 512, 100, validation_data=(test_x, test_y), callbacks=train_callbacks)