Keras:使用ft_generator和LSTM会引发错误:使用模型之前必须先对其进行编译

时间:2018-08-01 11:14:27

标签: keras lstm keras-layer

我关注了一些建议将input_shape输入到第一LSTM层的帖子,但仍然会产生此错误:

  model.add(TimeDistributed(Conv2D(32, kernel_size=(2, 2), activation='relu', input_shape=(100, 126, 1))))
  model.add(TimeDistributed(MaxPooling2D(pool_size=(2, 2))))
  model.add(TimeDistributed(Dropout(0.25)))
  model.add(TimeDistributed(Flatten()))

  model.add(LSTM(20, input_shape=(100, 62, 1), return_sequences=True))
  model.add(Dense(6, activation='sigmoid'))

  model.compile(loss=categorical_crossentropy, optimizer=sgd, metrics=['accuracy'])

  model.fit_generator(generator=train_gen, validation_data=val_gen)

0 个答案:

没有答案