keras RNN 运行 样本较少

keras RNN running on less samples

x = training_set_scaled
x = x.reshape(-1,1,12)
y = lab.to_numpy()
y = y.reshape(-1,1)

print(x)
print(y)
##(1127, 1,12)
##(1127, 1)

model = Sequential()

model.add(LSTM(units=128,activation='relu',return_sequences=True,
          input_shape=(1,12)))
#model.add(Dropout(0.1))

model.add(LSTM(units = 128,activation='relu'))
#model.add(Dropout(0.1))

model.add(Dense(100,activation='relu'))
#model.add(Dropout(0.1))

model.add(Dense(1,activation='softmax'))

opt = tf.keras.optimizers.Adam(lr=1e-3,decay=1e-5)

model.compile(loss='binary_crossentropy',optimizer=opt,metrics=['accuracy'])

print(model.summary())
model.fit(x,y,batch_size=10,epochs=20,verbose=2)

// 这是我的代码,但是 纪元 1/20 113/113 - 0s - 损失:7.8614 - 准确度:0.4845 为什么只有 113 个样本 运行ning

我正在尝试使用 keras 构建 RNN。 n.o 样本为 1127,每个样本有 12 个变量。 输出是简单的 0 或 1,但是当我 运行 模型时,它 运行 仅在 113 个样本上。有人可以帮帮我吗。我在这里呆了三天 谢谢你

它不是 运行 113 个样本,它是 运行 每个大小为 10 的“113 个小批量”。

model.fit(x,y,batch_size=10,epochs=20,verbose=2)

此处您已将批量大小指定为 10,因此它使用 10 个样本训练模型 113 次,即 10*113 = 1130 个样本总数。 (它只在 7 上训练最后一个小批量,因为只剩下这些了)