SQUAD_DIR=./data/squad_1_1/
BERT_BASE_DIR=./models/cased_L-12_H-768_A-12/
nohup python3 run_squad.py
--vocab_file=$BERT_BASE_DIR/vocab.txt
--bert_config_file=$BERT_BASE_DIR/bert_config.json
--init_checkpoint=$BERT_BASE_DIR/bert_model.ckpt
--do_train=True
--train_file=$SQUAD_DIR/train-v1.1.json
--do_predict=True
--predict_file=$SQUAD_DIR/dev-v1.1.json
--train_batch_size=12
--learning_rate=3e-5
--num_train_epochs=2.0
--max_seq_length=384
--doc_stride=128
--output_dir=./output/ > output.txt &
INFO:tensorflow:start_position: 59
INFO:tensorflow:end_position: 63
INFO:tensorflow:answer: f ##eb ##ru ##ary 1848
INFO:tensorflow:***** Running training *****
INFO:tensorflow: Num orig examples = 87599
INFO:tensorflow: Num split examples = 88245
INFO:tensorflow: Batch size = 12
INFO:tensorflow: Num steps = 14599
INFO:tensorflow:Calling model_fn.
INFO:tensorflow:Running train on CPU
INFO:tensorflow:*** Features ***
INFO:tensorflow: name = end_positions, shape = (12,)
INFO:tensorflow: name = input_ids, shape = (12, 384)
INFO:tensorflow: name = input_mask, shape = (12, 384)
INFO:tensorflow: name = segment_ids, shape = (12, 384)
INFO:tensorflow: name = start_positions, shape = (12,)
INFO:tensorflow: name = unique_ids, shape = (12,)
Traceback (most recent call last):
File "run_squad.py", line 1170, in
tf.app.run()
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "run_squad.py", line 1104, in main
estimator.train(input_fn=train_input_fn, max_steps=num_train_steps)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 376, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1145, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1170, in _train_model_default
features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2162, in _call_model_fn
features, labels, mode, config)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1133, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2391, in _model_fn
features, labels, is_export_mode=is_export_mode)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 1244, in call_without_tpu
return self._call_model_fn(features, labels, is_export_mode=is_export_mode)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 1505, in _call_model_fn
estimator_spec = self._model_fn(features=features, **kwargs)
File "run_squad.py", line 581, in model_fn
tvars, init_checkpoint)
File "/home/zzt/bert/modeling.py", line 331, in get_assigment_map_from_checkpoint
init_vars = tf.train.list_variables(init_checkpoint)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/python/training/checkpoint_utils.py", line 94, in list_variables
reader = load_checkpoint(ckpt_dir_or_file)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/python/training/checkpoint_utils.py", line 63, in load_checkpoint
return pywrap_tensorflow.NewCheckpointReader(filename)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 306, in NewCheckpointReader
return CheckpointReader(compat.as_bytes(filepattern), status)
File "/usr/local/python3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 519, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for ./models/cased_L-12_H-768_A-12//bert_model.ckpt
I have solved this bug by --init_checkpoint=$BERT_BASE_DIR and change the file "checkpoint"
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Saving checkpoints for 0 into ./output/model.ckpt.
INFO:tensorflow:global_step/sec: 1.25546
INFO:tensorflow:examples/sec: 15.0656
INFO:tensorflow:global_step/sec: 1.31054
INFO:tensorflow:examples/sec: 15.7265
Thanks robotzheng, I met same issue and solved
I think the issue is just the double slash here: ./models/cased_L-12_H-768_A-12//bert_model.ckpt
I get the same issue when my path has a double slash, and it works fine when it doesn't.
I.e., BERT_BASE_DIR=./models/cased_L-12_H-768_A-12 should work.
(I'm not sure why TensorFlow isn't robust to paths with double slashes though).
The checkpoint file in BERT_BASE_DIR was actually a mistake, I just uploaded new versions with those removed.