vincent131499 / textclassifier_transformer Goto Github PK
View Code? Open in Web Editor NEW个人基于谷歌开源的BERT编写的文本分类器(基于微调方式),可自由加载NLP领域知名的预训练语言模型BERT、Bert-wwm、Roberta、ALBert以及ERNIE1.0
个人基于谷歌开源的BERT编写的文本分类器(基于微调方式),可自由加载NLP领域知名的预训练语言模型BERT、Bert-wwm、Roberta、ALBert以及ERNIE1.0
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
2020-05-11 10:06:38.571054: I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations: AVX AVX2
To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags.
2020-05-11 10:06:38.574442: I tensorflow/core/common_runtime/process_util.cc:115] Creating new thread pool with default inter op setting: 12. Tune using inter_op_parallelism_threads for best performance.
WARNING:tensorflow:From D:\anaconda\lib\site-packages\tensorflow\contrib\predictor\saved_model_predictor.py:153: load (from tensorflow.python.saved_model.loader_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.loader.load or tf.compat.v1.saved_model.load. There will be a new function for importing SavedModels in Tensorflow 2.0.
WARNING:tensorflow:From D:\anaconda\lib\site-packages\tensorflow\python\training\saver.py:1276: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
WARNING:tensorflow:From D:\pycharm\sentiment\bert\tokenization.py:125: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.
Process finished with exit code -1073741819 (0xC0000005)
网上的方法都试了,能否请您告知是什么原因?
问题同标题, 我这边自己预训练 并且finetune 了一个分类任务的electra 模型 想用tfserving 来预测 请问可以吗
这个脚本可以直接加载项目中罗列的模型么?还是只契合roberta
你好,请问后期会有albert_zh的中文文本分类模型应用吗?
input_fn = tf.estimator.export.build_raw_serving_input_receiver_fn({
'label_ids': label_ids,
'input_ids': input_ids,
'input_mask': input_mask,
'segment_ids': segment_ids,
})()
少了后面那个括号,排查了好久。。。
报错信息为:
Shape of Variable bert/embeddings/word_embeddings:0((21128, 312)) doesn't match with shape of tensor bert/embeddings/word_embeddings([21128, 128]) from checkpoint reader.
在albert配置文件里,有:
"hidden_size": 312,
"embedding_size": 128
直接用test_serving线下加载模型预测的模式,外层用flask封装一下,是不是也能做成线上的形式
Traceback (most recent call last):
File "run_classifier_serving.py", line 1087, in
tf.app.run()
File "/data/aif/common/anaconda/envs/py3nlp_todd/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/data/aif/common/anaconda/envs/py3nlp_todd/lib/python3.6/site-packages/absl/app.py", line 300, in run
_run_main(main, args)
File "/data/aif/common/anaconda/envs/py3nlp_todd/lib/python3.6/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "run_classifier_serving.py", line 1077, in main
estimator.export_saved_model(FLAGS.export_dir, serving_input_fn)
File "/data/aif/common/anaconda/envs/py3nlp_todd/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 732, in export_saved_model
strip_default_attrs=True)
File "/data/aif/common/anaconda/envs/py3nlp_todd/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 829, in _export_all_saved_models
export_dir = export_lib.get_timestamped_export_dir(export_dir_base)
File "/data/aif/common/anaconda/envs/py3nlp_todd/lib/python3.6/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py", line 216, in get_timestamped_export_dir
compat.as_bytes(export_dir_base), compat.as_bytes(str(timestamp)))
File "/data/aif/common/anaconda/envs/py3nlp_todd/lib/python3.6/site-packages/tensorflow/python/util/compat.py", line 65, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got None
Traceback (most recent call last):
File "run_classifier_serving.py", line 1086, in
tf.app.run()
File "/home/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/.local/lib/python3.6/site-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/home/.local/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "run_classifier_serving.py", line 901, in main
bert_config = modeling.BertConfig.from_json_file(FLAGS.bert_config_file)
File "/home/.local/share/Trash/files/TextClassifier_BERT-master/modeling.py", line 93, in from_json_file
text = reader.read()
File "/home/.local/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 122, in read
self._preread_check()
File "/home/.local/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 84, in _preread_check
compat.as_bytes(self.__name), 1024 * 512)
tensorflow.python.framework.errors_impl.NotFoundError: ./chinese_roberta_zh_l12/bert_config.json; No such file or directory
hello,想请教一下f1的计算方式:
您这里是这样计算的:f1 = (2 * precision[0] * recall[0] / (precision[0] + recall[0]),recall[1]),这里f1的update只用了recall,请问是怎么考虑的呢?
我觉得应该是这样:f1_update = 2 * update_op_precision * update_op_recall / (update_op_precision + update_op_recall + eps)
麻烦了,多谢多谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.