【问题标题】:how should i fixed problem with " ValueError: Input 0 of layer "sequential" is incompatible with the layer expected shape=(None, 25, 1)"我应该如何解决“ValueError: Input 0 of layer "sequential" is in compatible with the layer expected shape=(None, 25, 1)"
【发布时间】:2022-07-15 22:02:41
【问题描述】:
# Initialising the RNN
regressor = Sequential()

# Adding the first LSTM layer and some Dropout regularisation
regressor.add(LSTM(units = 64, return_sequences = True, input_shape = (X_train.shape[1], 1),activation="sigmoid"))
regressor.add(Dropout(0.2))

# Adding a second LSTM layer and some Dropout regularisation
regressor.add(LSTM(units = 64, return_sequences = True))
regressor.add(Dropout(0.2))

# Adding a third LSTM layer and some Dropout regularisation
regressor.add(LSTM(units = 64, return_sequences = True))
regressor.add(Dropout(0.2))
# Adding a fourth LSTM layer and some Dropout regularisation
regressor.add(LSTM(units = 64))
regressor.add(Dropout(0.2))

# Adding the output layer
regressor.add(Dense(units = 1))

# Compiling the RNN
regressor.compile(optimizer = 'adam', loss = 'mean_squared_error')

# Fitting the RNN to the Training set
regressor.fit(X_train, y_train, epochs = 200, batch_size = 5)
timestep = 45
def insert_end(Xin,new_input):
    for i in range(timestep-1):
        Xin[:,i,:] = Xin[:,i+1,:]
    Xin[:,timestep-1,:] = new_input
    return Xin

future = 100
forcast = []
Xin = X_test[-1:]
for i in range(future):
    out = regressor.predict(Xin, batch_size=1)    
    forcast.append(out[0,0]) 
    Xin = insert_end(Xin,out[0,0])

我想预测未来的预测值,但我收到类似“ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 25, 1), found shape =(None, 5, 1)",我该怎么办?

【问题讨论】:

  • 什么是X_train形状和Xin形状?

标签: python tensorflow keras deep-learning lstm


【解决方案1】:

我认为这与我现在要发布的问题相同。值错误。 我正在使用 CASIA-Multi-Spectral-PalmprintV1 数据集研究手掌静脉生成模型。 请问您解决了这个问题吗?

【讨论】:

    猜你喜欢
    • 2022-09-24
    • 2022-01-03
    • 1970-01-01
    • 2022-11-06
    • 2022-09-30
    • 2021-12-14
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    相关资源
    最近更新 更多