针对多标签问题的 scikit 学习链分类器与 keras 模型的拟合方法误差

Error in fit method of scikit learn chain classifier with a keras model for a multilabel problem

我正在为使用 KerasClassifier 模型的多类问题构建链分类器。我有 17 个标签作为分类目标, X_train 的形状是 (111300,107) 并且 y_train 是 (111300,17) 我的代码在这里:

def create_model():
  input_size=length_long_sentence
  embedding_size=128
  lstm_size=64
  output_size=len(unique_tag_set)
    #----------------------------Model -------------------------------
  current_input=Input(shape=(input_size,)) 
  emb_current = Embedding(vocab_size, embedding_size, input_length=input_size)(current_input)
  out_current=Bidirectional(LSTM(units=lstm_size))(emb_current )
  #out_current = Reshape((1,2*lstm_size))(out_current)
  output = Dense(units=len(unique_tag_set), activation='softmax')(out_current)
  model = Model(inputs=current_input, outputs=output)
  model.compile(optimizer='Adam', loss='categorical_crossentropy', metrics=['accuracy'])
  print(model.summary())
  return model

   model = KerasClassifier(build_fn=create_model, epochs=1,batch_size=256)
   print(type(model))
   chain=ClassifierChain(model, order='random', random_state=42)
   history=chain.fit(X_train, y_train)

模型摘要在这里:

当尝试在 ClassifierChain 上使用 fit 方法时,我收到此错误:

任何人都可以指导我解决这个错误,什么是 (None,2)?

来自链式分类器的文档:

A multi-label model that arranges binary classifiers into a chain.

因此,在最后一层使用单个节点并将损失函数转换为二元分类器 binary_crossentropy