Py之torchtext:torchtext库的简介、安装、使用方法之详细攻略
目录
torchtext库的简介
torchtext库是PyTorch项目的一部分。PyTorch 是一个开源机器学习框架。该torchtext软件包由数据处理实用程序和流行的自然语言数据集组成。
官方API文档:torchtext — Torchtext 0.15.0 documentation
torchtext库的安装
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torchtext
pip install torchtext==0.10.0
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torchtext==0.10.0
torchtext库的使用方法
1、基础案例
from torchtext.data import Field
tokenize = lambda x:x.split()
TEXT = Field(sequential = True, tokenize = tokenize, lower = True)
LABEL = Field(sequential = False, use_vocab = False)