bojone / bert4keras

keras implement of transformers for humans
https://kexue.fm/archives/6915
Apache License 2.0
5.37k stars 927 forks source link

运行双卡gpu训练实体识别例子出现crf报错 #292

Open cronousbaby opened 3 years ago

cronousbaby commented 3 years ago

提问时请尽可能提供如下信息:

基本信息

核心代码

# 请在此处贴上你的核心代码。
# 请尽量只保留关键部分,不要无脑贴全部代码。

with strategy.scope(): bert = build_transformer_model( config_path, checkpoint_path=None, return_keras_model=False ) model = bert.model output_layer = 'Transformer-%s-FeedForward-Norm' % (bert_layers - 1) output = model.get_layer(output_layer).output output = Dense(num_labels)(output) CRF = ConditionalRandomField(lr_multiplier=crf_lr_multiplier) output = CRF(output)

model = Model(model.input, output)

model.compile(
    loss=CRF.sparse_loss,
    optimizer=Adam(learing_rate),
    metrics=[CRF.sparse_accuracy]
)
model.summary()

输出信息


# 请在此处贴上你的调试输出
```tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable conditional_random_field/trans from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/conditional_random_field/trans/N10tensorflow3VarE does not exist.
     [[{{node ReadVariableOp}}]]

### 自我尝试
不管什么问题,请先尝试自行解决,“万般努力”之下仍然无法解决再来提问。此处请贴上你的努力过程。
bojone commented 3 years ago

没测过RNN模型,我记得RNN模型做并行也是各种坑的,暂时不建议使用啊。

cronousbaby commented 3 years ago

好的,谢谢苏神,有没有计划实现RNN模型的多卡训练呢

bojone commented 3 years ago

这个只能有空试试了,不打包票~