4AI/TDEER

rel_model = Model(bert_model.input, [pred_rels])这句代码的问题

Closed this issue · 2 comments

tokens_feature = bert_model.output

pred_rels = L.Lambda(lambda x: x[:, 0])(tokens_feature)
pred_rels = L.Dense(relation_size, activation='sigmoid', name='pred_rel')(pred_rels)
rel_model = Model(bert_model.input, [pred_rels])
我看的输入的应该是bert_model.output鸭,为什么rel_model = Model(bert_model.input, [pred_rels])这句代码的输入是bert_model.input可以解释一下嘛,万分感谢

@jielunzhou18754 你好,这个输入就是 model.input。
rel_model 用到了 bert 的输出产物 (对应代码中的 L58 ), rel_model 和 bert_model 是共享输入的 placeholder 的,而 bert_model.input 存储的正是输入的 placeholder,所以这里传的是 bert_model.input 而不是 bert_model.output

静态图的构图方式跟动态图的不太一样,还是需要仔细想想。

好的,感谢您的回复,我再去深入的看看代码,祝您生活愉快