一些有用的代码
poros的Python项目详细描述
这是一个以后懒惰工作的项目! 只支持python3,,但也许您可以尝试python2
安装
命
pip install poros
从
git clone https://github.com/diqiuzhuanzhuan/poros.git
cd poros
python setup install
有些代码是别人的,有些是我的。
Bert_模型
用法:
- 创建预训练数据
fromporos.bert_modelimportcreate_pretraining_data>>>create_pretraining_data.create_data(input_file="./test_data/sample_text.txt",output_file="./test_data/output",vocab_file="./test_data/vocab.txt")
- 预训练伯特模型
fromporos.bert_modelimportpretrain>>>pretrain.run(input_file="./test_data/output",bert_config_file="./test_data/bert_config.json",output_dir="./output")
- 准备一个经过训练的模型,告诉分类器模型
- 准备train.csv和test.csv,其格式是这样的:“id,text1,label”,但不要记住标题!
- 在模型中,代码如下
fromporos.bert_model.run_classifierimportSimpleClassifierModel>>>model=SimpleClassifierModel(bert_config_file="./data/chinese_L-12_H-768_A-12/bert_config.json",vocab_file="./data/chinese_L-12_H-768_A-12/vocab.txt",output_dir="./output",max_seq_length=512,train_file="./data/train.csv",dev_file="./data/dev.csv",init_checkpoint="./data/chinese_L-12_H-768_A-12/bert_model.ckpt",label_list=["0","1","2","3"])
Poros_数据集
关于张量的一些运算
fromporos.poros_datasetimportabout_tensorimporttensorflowastf>>>A=tf.constant(value=[0])>>>print(about_tensor.get_shape(A))[1]
poros_chars
提供小功能列表
用法:
- 将中文单词转换成阿拉伯数字:
fromporos.poros_charsimportchinese_to_arabic>>>print(chinese_to_arabic.NumberAdapter.convert("四千三百万"))43000000