我是深度学习的新手,我正在尝试使用Google Colab在Keras中创建这种简单的RNN架构:
以下是我的代码:
train_x, valid_x = model_selection.train_test_split(df_tea,random_state=2, stratify=df_tea['offer_Offer'])
train_x.shape
=> (4982, 12)
valid_x.shape
=> (1661, 12)
model = Sequential()
model.add(Dense(12))
model.add(Activation("relu"))
model.add(SimpleRNN(1 , input_shape=(128, 12)))
model.add(Activation("relu"))
model.add(Dense(1))
model.add(Activation("softmax"))
model.compile(optimizer='rmsprop', loss='binary_crossentropy', metrics=['acc'])
history = model.fit(train_x.values, valid_x.values,
epochs=10,
batch_size=128,
validation_split=0.2)
运行model.compile时,出现此错误:
ValueError:输入0与图层simple_rnn_7不兼容:预期ndim = 3,找到ndim = 2
请帮助我,因为我不明白这意味着什么。请让我知道是否需要更多信息。