一些有用的代码

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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java无法启动应用程序:JNLP错误   java根据用户输入在PreparedStatement中使用setTime()或setNull()   java EJB与同步   java以object为键通过hashmap进行搜索   java中的模10^9+7   针对包含其他对象的对象的java OOP最佳实践   如何将字符串作为HTML代码从Java文件读取到JSP页面?   java我的POM怎么了?“解析表达式..检测到递归表达式循环”   用于Hbase的Mapreduce的java NoSuchMethodError   JAVAlang.SecurityException:权限拒绝:启动意图{act=安卓.Intent.action.MAIN cat=[安卓.Intent.category.LAUNCHER]   数组初始化谜语Java   通过arraylist搜索时的java句柄关联