model_path = r"E:/Project/uncased_L-2_H-128_A-2/"
bert = load_trained_model_from_checkpoint(
model_path + "bert_config.json",
model_path + "bert_model.ckpt",
seq_len=self.max_seq_length
)
#make bert layer trainable
for layer in bert.layers:
layer.trainable = True
x1 = Input(shape=(None,))
x2 = Input(shape=(None,))
bert_out = bert([x1, x2])
print( bert_out.shape )
print( type(bert_out) )
print( x2.shape )
print( type(x2) )
x3 = tf.reshape( x2,[-1,-1,1] )
print( x3.shape )
print( type(x3) )
cc = concatenate([bert_out, x3])
print( cc.shape )
print( type(cc) )
print( self.lstmDim )
lstm_out = Bidirectional(LSTM(self.lstmDim,
return_sequences=True,
dropout=0.2,
recurrent_dropout=0.2
))( cc ) #
print( lstm_out.shape )
print( type(lstm_out) )
crf_out = CRF(len(self.label), sparse_target=True)( lstm_out )
model = Model([x1, x2], crf_out)
model.summary()
Я пытаюсь объединить дополнительную информацию с LSTM, но получаю ошибку. Почему мой LSTM тусклый 128 ,, а мой входной тусклый 129?
(?, ?, 128)
<class 'tensorflow.python.framework.ops.Tensor'>
(?, ?)
<class 'tensorflow.python.framework.ops.Tensor'>
(?, ?, 1)
<class 'tensorflow.python.framework.ops.Tensor'>
(?, ?, 129)
<class 'tensorflow.python.framework.ops.Tensor'>
64
(?, ?, 128)
<class 'tensorflow.python.framework.ops.Tensor'>
\keras\engine\network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1323 ValueError: if a cycle is detected.
1324 """
-> 1325 node = layer._inbound_nodes[node_index]
1326
1327 # Prevent cycles.
AttributeError: 'NoneType' object has no attribute '_inbound_nodes'