일단 간단하게 제대로 작동하나 보려고 한달치 데이터(21년 1월 31개 데이터)만 넣었는데

ValueError: Exception encountered when calling layer "sequential_13" (type Sequential).

Input 0 of layer "lstm_13" is incompatible with the layer: expected ndim=3, found ndim=1. Full shape received: (None,)

이런 정체불명의 에러가 뜹니다.

이거 찾아봐도 상황이 다 다르니 어떻게 처리해야되는지를 모르겠네요


아래는 에러가 난 코드입니다.

validation_steps 부분에서 위에 나온 에러가 계속 뜨는데 진짜 1부터 쭉 넣어봐도 계속 저 에러가 뜨고있습니다.


아 참고로 밑에 batch size~echos 네개 변수는 20 이하로 변수를 계속 바꿔서 돌려봤는데 계속 에러떠서 일단 원래 예제 데이터로 변경한 상태입니다.


+트레이닝 데이터는 20개로 설정했습니다.


진짜 어떤거를 바꿔야 되는지를 모르겠어서 에러부분 코드 올립니다..도와주세요 ㅜㅜ


BATCH_SIZE = 256
BUFFER_SIZE = 10000
EVALUATION_INTERVAL = 200
EPOCHS = 10
train_data_single = tf.data.Dataset.from_tensor_slices((x_train_single, y_train_single))
train_data_single = train_data_single.cache().shuffle(BUFFER_SIZE).batch(BATCH_SIZE).repeat()

val_data_single = tf.data.Dataset.from_tensor_slices((x_val_single, y_val_single))
val_data_single = val_data_single.batch(BATCH_SIZE).repeat()

single_step_model = tf.keras.models.Sequential()
single_step_model.add(tf.keras.layers.LSTM(32, input_shape=x_train_single.shape[-2:]))
single_step_model.add(tf.keras.layers.Dense(1))
single_step_model.compile(optimizer=tf.keras.optimizers.RMSprop(), loss='mae')

for x, y in val_data_single.take(1):
    print(single_step_model.predict(x).shape)

single_step_history = single_step_model.fit(train_data_single, epochs=EPOCHS,
                                            steps_per_epoch=EVALUATION_INTERVAL,
                                            validation_data=val_data_single,
                                            validation_steps=50)

def plot_train_history(historytitle):
    loss = history.history['loss']
    val_loss = history.history['val_loss']
    epochs = range(len(loss))
    plt.figure()
    plt.plot(epochs, loss, 'b', label='Training loss')
    plt.plot(epochs, val_loss, 'r', label='Validation loss')
    plt.title(title)
    plt.legend()
    plt.show()

plot_train_history(single_step_history,
                   'Single Step Training and Validation Loss')