torchtext.get_tokenizer

部署运行你感兴趣的模型镜像

1. 说明

假设我们有一个句子如下:You can now install TorchText using pip!
分词后可得:['you', 'can', 'now', 'install', 'torchtext', 'using', 'pip', '!']

2. pytorch代码

import torchtext
from torchtext.data import get_tokenizer

tokenizer = get_tokenizer("basic_english")
tokens = tokenizer("You can now install TorchText using pip!")
print(tokens)
  • 结果:
['you', 'can', 'now', 'install', 'torchtext', 'using', 'pip', '!']

您可能感兴趣的与本文相关的镜像

PyTorch 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

C:\anaconda\envs\py39\python.exe C:\Users\32398\PyCharmMiscProject\深度学习\影评分类.py C:\anaconda\envs\py39\lib\site-packages\torchtext\datasets\__init__.py:4: UserWarning: /!\ IMPORTANT WARNING ABOUT TORCHTEXT STATUS /!\ Torchtext is deprecated and the last released version will be 0.18 (this one). You can silence this warning by calling the following at the beginnign of your scripts: `import torchtext; torchtext.disable_torchtext_deprecation_warning()` warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG) C:\anaconda\envs\py39\lib\site-packages\torchtext\data\__init__.py:4: UserWarning: /!\ IMPORTANT WARNING ABOUT TORCHTEXT STATUS /!\ Torchtext is deprecated and the last released version will be 0.18 (this one). You can silence this warning by calling the following at the beginnign of your scripts: `import torchtext; torchtext.disable_torchtext_deprecation_warning()` warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG) C:\anaconda\envs\py39\lib\site-packages\torchtext\vocab\__init__.py:4: UserWarning: /!\ IMPORTANT WARNING ABOUT TORCHTEXT STATUS /!\ Torchtext is deprecated and the last released version will be 0.18 (this one). You can silence this warning by calling the following at the beginnign of your scripts: `import torchtext; torchtext.disable_torchtext_deprecation_warning()` warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG) C:\anaconda\envs\py39\lib\site-packages\torchtext\utils.py:4: UserWarning: /!\ IMPORTANT WARNING ABOUT TORCHTEXT STATUS /!\ Torchtext is deprecated and the last released version will be 0.18 (this one). You can silence this warning by calling the following at the beginnign of your scripts: `import torchtext; torchtext.disable_torchtext_deprecation_warning()` warnings.warn(torchtext._TORCHTEXT_DEPRECATION_MSG) ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的模块。 Traceback (most recent call last): File "C:\Users\32398\PyCharmMiscProject\深度学习\影评分类.py", line 7, in <module> import matplotlib.pyplot as plt File "C:\anaconda\envs\py39\lib\site-packages\matplotlib\__init__.py", line 161, in <module> from . import _api, _version, cbook, _docstring, rcsetup File "C:\anaconda\envs\py39\lib\site-packages\matplotlib\rcsetup.py", line 27, in <module> from matplotlib.colors import Colormap, is_color_like File "C:\anaconda\envs\py39\lib\site-packages\matplotlib\colors.py", line 56, in <module> from matplotlib import _api, _cm, cbook, scale File "C:\anaconda\envs\py39\lib\site-packages\matplotlib\scale.py", line 22, in <module> from matplotlib.ticker import ( File "C:\anaconda\envs\py39\lib\site-packages\matplotlib\ticker.py", line 138, in <module> from matplotlib import transforms as mtransforms File "C:\anaconda\envs\py39\lib\site-packages\matplotlib\transforms.py", line 49, in <module> from matplotlib._path import ( ImportError: numpy.core.multiarray failed to import 进程已结束,退出代码为 1
最新发布
06-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值