- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是深度学习和 NLP 新手,现在尝试开始使用预训练的 Google BERT 模型。由于我打算用BERT构建一个QA系统,所以我决定从SQuAD相关的微调开始。
我按照 the official Google BERT GitHub repository 中的 README.md 中的说明进行操作.
我输入的代码如下:
export BERT_BASE_DIR=/home/bert/Dev/venv/uncased_L-12_H-768_A-12/
export SQUAD_DIR=/home/bert/Dev/venv/squad
python 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=/tmp/squad_base/
几分钟后(训练开始时),我得到了这个:
a lot of output omitted
INFO:tensorflow:start_position: 53
INFO:tensorflow:end_position: 54
INFO:tensorflow:answer: february 1848
INFO:tensorflow:***** Running training *****
INFO:tensorflow: Num orig examples = 87599
INFO:tensorflow: Num split examples = 88641
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,)
INFO:tensorflow:Error recorded from training_loop: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for /home/bert/Dev/venv/uncased_L-12_H-768_A-12//bert_model.ckpt
INFO:tensorflow:training_loop marked as finished
WARNING:tensorflow:Reraising captured error
Traceback (most recent call last):
File "run_squad.py", line 1283, in <module>
tf.app.run()
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "run_squad.py", line 1215, in main
estimator.train(input_fn=train_input_fn, max_steps=num_train_steps)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2400, in train
rendezvous.raise_errors()
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/contrib/tpu/python/tpu/error_handling.py", line 128, in raise_errors
six.reraise(typ, value, traceback)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/six.py", line 693, in reraise
raise value
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2394, in train
saving_listeners=saving_listeners
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 356, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 1181, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 1211, in _train_model_default
features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2186, in _call_model_fn
features, labels, mode, config)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 1169, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2470, in _model_fn
features, labels, is_export_mode=is_export_mode)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 1250, in call_without_tpu
return self._call_model_fn(features, labels, is_export_mode=is_export_mode)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 1524, in _call_model_fn
estimator_spec = self._model_fn(features=features, **kwargs)
File "run_squad.py", line 623, in model_fn
) = modeling.get_assignment_map_from_checkpoint(tvars, init_checkpoint)
File "/home/bert/Dev/venv/bert/modeling.py", line 330, in get_assignment_map_from_checkpoint
init_vars = tf.train.list_variables(init_checkpoint)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/python/training/checkpoint_utils.py", line 95, in list_variables
reader = load_checkpoint(ckpt_dir_or_file)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/python/training/checkpoint_utils.py", line 64, in load_checkpoint
return pywrap_tensorflow.NewCheckpointReader(filename)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 314, in NewCheckpointReader
return CheckpointReader(compat.as_bytes(filepattern), status)
File "/home/bert/Dev/venv/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 526, 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 /home/bert/Dev/venv/uncased_L-12_H-768_A-12//bert_model.ckpt
看来tensorflow未能找到检查点文件,但据我所知,一个tensorflow检查点"file"实际上是三个文件,这是正确的调用方法(带有路径和前缀)。
我相信我将文件放在正确的位置:
(venv) bert@bert-System-Product-Name:~/Dev/venv/uncased_L-12_H-768_A-12$ pwd
/home/bert/Dev/venv/uncased_L-12_H-768_A-12
(venv) bert@bert-System-Product-Name:~/Dev/venv/uncased_L-12_H-768_A-12$ ls
bert_config.json bert_model.ckpt.data-00000-of-00001 bert_model.ckpt.index bert_model.ckpt.meta vocab.txt
我正在 Ubuntu 16.04 LTS 上运行,配备 NVIDIA GTX 1080 Ti (CUDA 9.0),使用 Anaconda python 3.5 发行版,在虚拟环境中使用tensorflow-gpu 1.11.0。
我希望代码能够顺利运行并开始训练(微调),因为它是官方代码,并且我按照说明放置了文件。
最佳答案
我正在回答我自己的问题。
我刚刚通过简单地删除 $BERT_BASE_DIR
中的斜杠(/
) 解决了这个问题,因此变量从 '/home/bert/更改为Dev/venv/uncased_L-12_H-768_A-12/'
到 '/home/bert/Dev/venv/uncased_L-12_H-768_A-12'
。
因此前缀“/home/bert/Dev/venv/uncased_L-12_H-768_A-12//bert_model.ckpt”中不再有双斜杠
。
tensorflow 中的检查点恢复函数似乎认为单斜杠或双斜杠是不同的,因为我相信 bash 将它们解释为相同的。
关于python - 运行 run_squad.py 微调 Google BERT 模型(官方 Tensorflow 预训练模型)时,无法加载(恢复)TensorFlow 检查点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55547256/
有没有人对如何解决这个查询有任何想法? 有一张客户表和一张许可证表。每个客户可以有多个在不同时间到期的许可证,一些已经过期,一些还没有。如果我想选择至少拥有一个有效许可证的所有客户,我会这样做: SE
我一直在尝试微调 HuggingFace: Blendebot 的对话模型。我已经尝试过拥抱脸官方网站上给出的常规方法,它要求我们使用 trainer.train() 方法来完成。我也尝试过使用 .c
是否有内置的 JavaScript 字符串方法可以帮助我微调这段代码以确保它只找到与名称完全匹配的内容? 这是我的代码。 /*jshint multistr:true */ var text = "S
我需要微调我的 word2vec 模型。我有两个数据集,data1 和 data2。 到目前为止我所做的是: model = gensim.models.Word2Vec( data1
在苹果的应用程序中,我注意到滚动效果非常完美。一切都进展顺利,当你停下来时,它就停止了。您可以拥有一个巨大的图像并直接移动到任何位置,并且它会停留在那里。 我想提供相同的 UE,但对于我的应用程序,如
问题 请帮助理解以下问题的原因以及如何构建 Keras 模型以在 huggingface 的预训练模型之上进行微调。 目标 在 TFDistilBertForSequenceClassificatio
我正在尝试为不同的数据集和不同的算法绘制一堆 ROC 区域。 我有三个变量:“Scheme”指定使用的算法,“Dataset”是测试算法的数据集,以及“Area_under_ROC”。 我在 R 中使
我正在使用 CNN 进行面部表情识别。我使用 Keras 和 Tensorflow 作为后端。我的模型保存为 h5 格式。 我想重新训练我的网络,并使用 VGG 模型微调我的模型。 我如何使用 ker
我正在使用 NSControlTextEditingDelegate 自动完成内容在 NSSearchField 中输入我生成的自定义建议。complete: 消息发送到字段编辑器当文本更改时。 现在
我为 mnist 数据集开发了一个 3 层深度自动编码器模型,因为我只是这个微调范例的初学者,所以我正在练习这个玩具数据集 下面是代码 from keras import layers from k
在我的代码中有一个我正在计算的参数。在多次测试中,该参数应该为0。由于该参数是通过多次加减计算的,因此不完全为0,而是小于10^-10。目前我正在使用: double tol = pow(10,-10
我的应用程序中有一个微调器,但在单击某个项目时它不起作用。我得到了值,但 if 条件不起作用。 spinner.setOnItemSelectedListener(new AdapterView.On
我需要帮助调整我的 mysql 服务器以获得更好的性能。我有很多资源,但它仍然表现不佳。我打得最多的一张表只有350万条记录。 我需要帮助关注更改哪些设置以获得更好的性能。 像这样的简单查询 SELE
在keras blog上有一个VGG16微调的例子,但我无法重现它。 更准确地说,这里是用于在没有顶层的情况下初始化 VGG16 并卡住除最顶层以外的所有 block 的代码: WEIGHTS_PAT
我正在尝试创建一个 Activity RateCardActivity,其中有一个微调器。 RateCardActivity 的布局文件是 rate_card。我的 RateCardActivity
微调器 xml: 我试过使用 android:background=... 自己购买,使用 dropDownSelector,使用和不使用 listSelector=...; 使用和不使用 list
我精心制作了下面列出组成员的命令: gwmi win32_group -filter 'Name="Administrators"'|%{$_.GetRelated('Win32_UserAccoun
已成功构建 HTML5 应用程序。以下库用于此: jquery.mobile-1.1.1.min.js jquery.mobile-1.1.1.min lawnchair.js 一切正常用 Phone
我在使用 Keras 微调 Inception 模型时遇到问题。 我已经成功地使用教程和文档生成了一个完全连接的顶层模型,该模型使用 Inception 中的瓶颈特征将我的数据集分类到正确的类别中,准
我对 PyTorch 和 Huggingface-transformers 比较陌生,并在此 Kaggle-Dataset 上试验过 DistillBertForSequenceClassificat
我是一名优秀的程序员,十分优秀!