'LSTM Time step?
Good afternoon to everyone,
I am kind of a newbie in programming so I am sorry if I make stupid comments of questions
I was building an LSTM model in which I have 4 different inputs such as air temp, air humidity, wind speed etc... and I need to produce an output of wind power forecast.
MY dataset is one year long and the time step is 1 hour. I first struggled when making the LSTM as I needed my input dimension to be 3D andI found a solution online and applied it. But now I need to change my time step to see what performs better in my model but I do not have any idea in how to change it.
My code looks like:
import tensorflow as tf
import csv
from sklearn.model_selection import train_test_split
import numpy as np
import matplotlib.pyplot as plt
import time
#Read DATA
with open("full_year_data.csv") as f:
reader = csv.reader(f)
next(reader)
data = []
for row in reader:
data.append({
"inputs": [float(cell) for cell in row[:4]],
"output": [float(cell) for cell in row[4:]]
})
#separate data into training and testing groups
inputs = [row["inputs"] for row in data]
inputs = np.array(inputs) #shape = (743, 4)
output = [row["output"] for row in data]
output = np.array(output) #shape= (743,1)
X_training, X_testing, y_training, y_testing = train_test_split(
inputs, output, test_size=0.25
)
X_training = np.expand_dims(X_training,1)
X_testing = np.expand_dims(X_testing,1)
nodes_hidden =
Learning_algorithm = tf.keras.optimizers.Adam()
model2 = tf.keras.models.Sequential()
model2.add(tf.keras.layers.LSTM(units = nodes_hidden, return_sequences =True, input_shape=X_training.shape[1:], activation='relu'))
model2.add(tf.keras.layers.LSTM(units = nodes_hidden, return_sequences =True, activation='relu'))
model2.add(tf.keras.layers.LSTM(units = nodes_hidden, return_sequences =True, activation='relu'))
model2.add(tf.keras.layers.LSTM(units = nodes_hidden, return_sequences =True, activation='relu'))
model2.add(tf.keras.layers.Dense(1, activation='sigmoid'))
model2.compile(optimizer = 'adam', loss = 'mean_squared_error')
model2.fit(X_training, y_training, epochs=100, batch_size=0)
model2.evaluate(X_testing, y_testing, verbose=2)
I am using Tensorflow and keras to make my LSTM model, any help on how I can change my time steps for testing will be really appreciate it
Thanks for yout time!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
