I have an LSTM network and I use it to predict. My whole data is an array with 10 rows and 1000 columns (10, 1000)
. I want to divide the data to train with size (10, 600)
, validate (10, 200)
and test (10, 200)
. When I have the train data, I want to change the data to a an array with size (10*600, 1)
and then train the model. However, in the tensorflow, we have validation_split
and I am not sure that this validation is same as the method that I want. Here is a simple example:
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow import keras
from keras.models import Sequential
from keras.layers import LSTM, Dense, Dropout
from keras.layers.recurrent import LSTM
X_total = np.randm.rand(10, 1000)
#here is an example with a sample data
X_train = np.random.rand(10,5,2)
Y_train = np.random.rand(10,2)
X_test = np.random.rand(3, 5, 2)
model = Sequential()
model.add(LSTM(64, activation='relu', input_shape=(X_train.shape[1], X_train.shape[2]), return_sequences=True))
model.add(LSTM(32, activation='relu', return_sequences=False))
model.add(Dropout(0.2))
model.add(Dense(Y_train.shape[1], kernel_regularizer='l2'))
opt = keras.optimizers.Adam(learning_rate=0.001)
model.compile(optimizer=opt, loss='mse')
history = model.fit(X_train, Y_train, epochs=1, batch_size=200, validation_split=0.1,verbose=1)
prediction = model.predict(X_test)