...
going to restore checkpoint
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /content/drive/Shared drives/teamDrive/BERT-BiLSTM-CRF-NER/bert_base/bert/modeling.py:673: dense (from tensorflow.python.layers.core) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.dense instead.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/contrib/crf/python/ops/crf.py:567: dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `keras.layers.RNN(cell)`, which is equivalent to this API
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn.py:626: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
{1: 'X', 2: 'B-PER', 9: 'I-PER', 5: 'O', 6: 'I-LOC', 7: 'B-ORG', 8: 'I-ORG', 4: '[SEP]', 3: '[CLS]', 10: 'B-LOC'}
input the test sentence:
阿萨姆奶茶比喜茶好喝多了
2020-04-30 04:57:09.061334: I tensorflow/stream_executor/dso_loader.cc:152] successfully opened CUDA library libcublas.so.10.0 locally
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1334, in _do_call
return fn(*args)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value bert/encoder/layer_5/attention/output/LayerNorm/beta
[[{{node bert/encoder/layer_5/attention/output/LayerNorm/beta/read}}]]
[[{{node rnn_1/while/Switch_2}}]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "terminal_predict.py", line 350, in <module>
predict_online()
File "terminal_predict.py", line 113, in predict_online
pred_ids_result = sess.run([pred_ids], feed_dict)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1328, in _do_run
run_metadata)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value bert/encoder/layer_5/attention/output/LayerNorm/beta
[[node bert/encoder/layer_5/attention/output/LayerNorm/beta/read (defined at /content/drive/Shared drives/teamDrive/BERT-BiLSTM-CRF-NER/bert_base/bert/modeling.py:366) ]]
[[node rnn_1/while/Switch_2 (defined at /content/drive/Shared drives/teamDrive/BERT-BiLSTM-CRF-NER/bert_base/train/lstm_crf_layer.py:62) ]]
Caused by op 'bert/encoder/layer_5/attention/output/LayerNorm/beta/read', defined at:
File "terminal_predict.py", line 64, in <module>
dropout_rate= 1.0
File "/content/drive/Shared drives/teamDrive/BERT-BiLSTM-CRF-NER/bert_base/train/models.py", line 89, in create_model
use_one_hot_embeddings=use_one_hot_embeddings
File "/content/drive/Shared drives/teamDrive/BERT-BiLSTM-CRF-NER/bert_base/bert/modeling.py", line 217, in __init__
do_return_all_layers=True)
File "/content/drive/Shared drives/teamDrive/BERT-BiLSTM-CRF-NER/bert_base/bert/modeling.py", line 865, in transformer_model
attention_output = layer_norm(attention_output + layer_input)
File "/content/drive/Shared drives/teamDrive/BERT-BiLSTM-CRF-NER/bert_base/bert/modeling.py", line 366, in layer_norm
inputs=input_tensor, begin_norm_axis=-1, begin_params_axis=-1, scope=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
return func(*args, **current_args)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/contrib/layers/python/layers/layers.py", line 2300, in layer_norm
trainable=trainable)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
return func(*args, **current_args)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/contrib/framework/python/ops/variables.py", line 350, in model_variable
aggregation=aggregation)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
return func(*args, **current_args)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/contrib/framework/python/ops/variables.py", line 277, in variable
aggregation=aggregation)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variable_scope.py", line 1479, in get_variable
aggregation=aggregation)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variable_scope.py", line 1220, in get_variable
aggregation=aggregation)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variable_scope.py", line 547, in get_variable
aggregation=aggregation)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variable_scope.py", line 499, in _true_getter
aggregation=aggregation)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variable_scope.py", line 911, in _get_single_variable
aggregation=aggregation)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 213, in __call__
return cls._variable_v1_call(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 176, in _variable_v1_call
aggregation=aggregation)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 155, in <lambda>
previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variable_scope.py", line 2495, in default_variable_creator
expected_shape=expected_shape, import_scope=import_scope)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 217, in __call__
return super(VariableMetaclass, cls).__call__(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 1395, in __init__
constraint=constraint)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/variables.py", line 1557, in _init_from_args
self._snapshot = array_ops.identity(self._variable, name="read")
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/array_ops.py", line 81, in identity
ret = gen_array_ops.identity(input, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3890, in identity
"Identity", input=input, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
op_def=op_def)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 1801, in __init__
self._traceback = tf_stack.extract_stack()
FailedPreconditionError (see above for traceback): Attempting to use uninitialized value bert/encoder/layer_5/attention/output/LayerNorm/beta
[[node bert/encoder/layer_5/attention/output/LayerNorm/beta/read (defined at /content/drive/Shared drives/teamDrive/BERT-BiLSTM-CRF-NER/bert_base/bert/modeling.py:366) ]]
[[node rnn_1/while/Switch_2 (defined at /content/drive/Shared drives/teamDrive/BERT-BiLSTM-CRF-NER/bert_base/train/lstm_crf_layer.py:62) ]]
作者你好,我运行bert-base-ner-train之后,再运行terminal_predict.py,返回了FailedPreconditionError: Attempting to use uninitialized value的错误,请问这是什么原因呢?
这是我工作空间的目录结构(为了节省展示空间,省略了一部分的目录)
运行bert-base-ner-train采用的参数
训练结束后,运行terminal_predict.py的报错