资源简介
完整的bert模型源代码,对代码做了很多注释和精简,以中文文本分类为例的一个deom,可以拿来就用,把代码稍微改改就可用在你的任务中。
代码片段和文件信息
# coding: UTF-8
import time
import torch
import numpy as np
from train_eval import train init_network
from importlib import import_module
import argparse
from utils import build_dataset build_iterator get_time_dif
parser = argparse.ArgumentParser(description=‘Chinese Text Classification‘)
parser.add_argument(‘--model‘ type=str required=True help=‘choose a model: Bert ERNIE‘)
args = parser.parse_args()
if __name__ == ‘__main__‘:
dataset = ‘THUCNews‘ # 数据集
model_name = args.model # bert
x = import_module(‘models.‘ + model_name)
config = x.Config(dataset)
np.random.seed(1)
torch.manual_seed(1)
torch.cuda.manual_seed_all(1)
torch.backends.cudnn.deterministic = True # 保证每次结果一样
start_time = time.time()
print(“Loading data...“)
train_data dev_data test_data = build_dataset(config)
train_iter = build_iterator(train_data config)
dev_iter = build_iterator(dev_data config)
test_iter = build_iterator(test_data config)
time_dif = get_time_dif(start_time)
print(“Time usage:“ time_dif)
# train
model = x.Model(config).to(config.device)
train(config model train_iter dev_iter test_iter)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\
目录 0 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\ERNIE_pretrain\
文件 151 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\ERNIE_pretrain\README.md
文件 1066 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\LICENSE
文件 3130 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\README.md
目录 0 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\THUCNews\
目录 0 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\THUCNews\data\
文件 82 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\THUCNews\data\class.txt
文件 551313 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\THUCNews\data\dev.txt
文件 551596 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\THUCNews\data\test.txt
文件 9946122 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\THUCNews\data\train.txt
目录 0 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\bert_pretrain\
文件 191 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\bert_pretrain\README.md
目录 0 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\models\
文件 2346 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\models\ERNIE.py
文件 2315 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\models\bert.py
文件 3036 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\models\bert_CNN.py
文件 3776 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\models\bert_DPCNN.py
文件 3014 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\models\bert_RCNN.py
文件 2928 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\models\bert_RNN.py
目录 0 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\
文件 1313 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__init__.py
文件 4393 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__main__.py
目录 0 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__pycache__\
文件 1606 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__pycache__\__init__.cpython-37.pyc
文件 2365 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__pycache__\__main__.cpython-37.pyc
文件 1763 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__pycache__\convert_gpt2_checkpoint_to_pytorch.cpython-37.pyc
文件 1807 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__pycache__\convert_openai_checkpoint_to_pytorch.cpython-37.pyc
文件 1564 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__pycache__\convert_tf_checkpoint_to_pytorch.cpython-37.pyc
文件 3045 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__pycache__\convert_transfo_xl_checkpoint_to_pytorch.cpython-37.pyc
文件 7230 2019-10-26 09:17 Bert-Chinese-Text-Classification-Pytorch-master\pytorch_pretrained\__pycache__\file_utils.cpython-37.pyc
............此处省略31个文件信息
相关资源
- THE INNER WORKINGS OF WORD2VEC
- wikiqa 数据集
- 蚂蚁金服文本匹配竞赛训练数据
- Reinforcement Learning in Natural Language Pro
- Linear Algebra and its Application(4ed) Gi
- Computational Science and Engineering By Gilbe
- 自然语言处理技术
- 哈工大 同义词词林
- torchvision-0.5.0+cpu-cp36-cp36m-linux_x86_64.
- 中国ArcGIS矢量shp数据(到县界、Lamb
- Introduction.To.Applied.Mathematics
- NLPCC2014情感分类语料集+已经标注好
- 已预处理 NLP 英文语料库 新闻组 20
- visdom可视化需要的文件
- PyTorch 模型训练实用教程
- 中国ArcGIS数据Lambert投影
- 中文NLP命名实体识别序列标注工具Y
- Natural Language Processing with PyTorch - 201
- mobilenet_v2-6a65762b.pth
- Deep learning with Pytorch电子书 - Vishnu S
- tf-idf算法.zip
- PyTorch_tutorial_0.0.4_余霆嵩
- BosonNLP数据的情感词典
- 中文实体词典(NLP必备)
-
neural_st
yle_tutoria_code&papers.zip - NLPCC2013评估任务_中文微博观点要素抽
- NLPCC2014评估任务2_基于深度学习的情感
- webrtc中NLP处理
- 奔驰无人驾驶汽车 making bertha drive
- Neural Network Methods in Natural Language Pro
评论
共有 条评论