I have a question about creating LSTM Memory cell? About node size setting~!!!

Asked 2 years ago, Updated 2 years ago, 127 views

x_train = raw_train.loc[:, train_cols].values
y_train = raw_train.loc[:, test_cols].values

x_test = raw_test.loc[:, train_cols].values
y_test = raw_test.loc[:, test_cols].values

Normalization

min_max_scaler = MinMaxScaler()
min_max_scaler_label = MinMaxScaler()

x_train_scaled = min_max_scaler.fit_transform(x_train)
y_train_scaled = min_max_scaler_label.fit_transform(y_train)

x_test_scaled = min_max_scaler.transform(x_test)
y_test_scaled = min_max_scaler_label.transform(y_test)
def build_timeseries(mat, time_steps):
    dim_0 = mat.shape[0] - time_steps
    dim_1 = mat.shape[1]

    x = np.zeros((dim_0, time_steps, dim_1))
    y = np.zeros((dim_0,))

    for i in range(dim_0):
        x[i] = mat[i:time_steps + i]
        y[i] = mat[time_steps + i, 0]
    print('length of time-series i/o', x.shape, y.shape)
    return x,y
time_step = 1

x_train_scaled_time, y_train_scaled_time = build_timeseries(x_train_scaled, 1)
x_test_scaled_time, y_test_scaled_time = build_timeseries(x_test_scaled, 1)
def create_model(input_data):
    lstm_model = Sequential()
    lstm_model.add(LSTM(10, input_shape=(x_train_scaled_time.shape[1],x_train_scaled_time.shape[2])))
    lstm_model.add(Dense(1))
    lstm_model.compile(loss='mse', optimizer='adam')

    return lstm_model

I created the lstm code and proceeded

The number of train data is 42808 The number of test data is 30.

What I'm curious about is that the last paragraph code lstm_model.add (LSTM(10, input_shape=...) 10 is a memory cell? It's searched as a node, but is there any know-how to set this number?

python ai

2022-09-20 19:51

1 Answers

Or please tell me the exact name of the number part of LSTM(10, please).


2022-09-20 19:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.