问题描述
我正在尝试命名实体识别,这里是我的 x_train 和 x_test 的详细信息:
Shape X_train: (3555,120,1024) Shape X_test: (887,1024)
input = Input(shape=(120,))
word_embedding_size = 1024
model = Embedding(input_dim=n_words,output_dim=word_embedding_size,input_length=120)(input)
model = Bidirectional(LSTM(units=word_embedding_size,return_sequences=True,dropout=0.5,recurrent_dropout=0.5,kernel_initializer=k.initializers.he_normal()))(model)
model = LSTM(units=word_embedding_size * 2,kernel_initializer=k.initializers.he_normal())(model)
model = Timedistributed(Dense(n_tags,activation="relu"))(model) # prevIoUsly softmax output layer
crf = CRF(n_tags) # CRF layer
out = crf(model) # output
model = Model(input,out)
adam = k.optimizers.Adam(lr=0.0005,beta_1=0.9,beta_2=0.999)
model.compile(optimizer=adam,loss=crf.loss_function,metrics=[crf.accuracy,'accuracy'])
model.summary()
model.fit(X_train,y_train,validation_data=(X_test,y_test),epochs=10,batch_size=32)
错误是:
ValueError: Input 0 of layer bidirectional_14 is incompatible with the layer: expected ndim=3,found ndim=4. Full shape received: (None,1024,1024)
请帮帮我,我无法通过其他答案解决。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)