This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(future_day - 1): | |
out_logits, last_state = sess.run( | |
[model.logits, model.last_state], | |
feed_dict = { | |
model.X: np.expand_dims(df_log.iloc[-timestamp:], axis = 0), | |
model.hidden_layer: init_value, | |
}, | |
) | |
init_value = last_state | |
output_predict[df_log.shape[0]] = out_logits[-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for k in range(0, df_log.shape[0] - 1, timestamp): | |
index = min(k + timestamp, df_log.shape[0] -1) | |
# We take a datapoints from K to index as input: | |
batch_x = np.expand_dims(df_log.iloc[k : index, :].values, axis = 0) | |
# We take a datapoints from K+1 to index+1 as corresponding output for input: | |
batch_y = df_log.iloc[k + 1 : index + 1, :].values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Defining Network Architecture: | |
class Model: | |
def __init__(self,learning_rate,num_layers,size,size_layer,output_size,forget_bias = 0.1): | |
def lstm_cell(size_layer): | |
""" | |
Function to construct LSTM Layer | |
""" | |
return tf.nn.rnn_cell.LSTMCell(size_layer, state_is_tuple = False) | |
# Creating LSTM's Unit: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
minmax = MinMaxScaler().fit(df.iloc[:, 1:].astype('float32')) | |
df_log = minmax.transform(df.iloc[:, 1:].astype('float32')) | |
df_log = pd.DataFrame(df_log) |