![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
transformer
骑单车的王小二
切勿眼高于顶,谨记脚踏实地。
展开
-
pytorch-bert 调用预训练模型或自训模型 进行预测(可批量)
#载入训练好的模型import numpy as npimport torch from transformers import BertTokenizer, BertConfig, BertForSequenceClassification#加载训练好的模型model_name = 'bert-base-cased'MODEL_PATH = '你的模型路径'# tokenizer.encode_plus返回多句子在字典中的id,tokenizer.tokenize返回token# [C原创 2021-12-23 20:22:43 · 6147 阅读 · 1 评论 -
pytorch和cuda版本对应
https://pytorch.org/get-started/previous-versions/原创 2021-12-22 14:18:12 · 4148 阅读 · 0 评论 -
transformer bert微调实例---细节解读
源码来源:https://github.com/huggingface/transformers/tree/master/examples/pytorch/text-classification代码解读#!/usr/bin/env python# coding=utf-8""" Finetuning the library models for sequence classification on GLUE."""# You can also adapt this script on your原创 2021-12-22 10:52:38 · 2539 阅读 · 0 评论 -
transformer bert微调实例(文本分类,超详细解析)
官方参考文档:https://huggingface.co/docs/transformers/training#additional-resources#transformer bert微调实例:以imdb数据集为基础(二分类),进行文本分类任务的微调#进行下列步骤之前,要先安装好transformer和pytorch#导入数据,该数据集是一个具有三个键的字典:"train","test"和"unsupervised" 。我们使用"train"进行训练,使用 "test"进行验证。from da原创 2021-12-21 16:17:02 · 4355 阅读 · 1 评论