解决module ‘tensorflow_datasets.core.features‘ has no attribute ‘text‘

在TensorFlow官网教程中尝试加载文本时遇到AttributeError,原因在于`tfds.features.text.Tokenizer()`方法已弃用。为解决此问题,应当使用`tfds.deprecated.text.Tokenizer`替代。更新代码后,可以正常创建tokenizer对象进行文本分词操作。
部署运行你感兴趣的模型镜像

问题描述

TensorFlow官网学习加载文本的例子,执行tokenizer = tfds.features.text.Tokenizer()代码出现如下问题:

AttributeError                            Traceback (most recent call last)
<ipython-input-20-6f949be18afd> in <module>()
----> 1 tokenizer = tfds.features.text.Tokenizer()
      2 
      3 vocabulary_set = set()
      4 for text_tensor, _ in all_labeled_data:
      5   some_tokens = tokenizer.tokenize(text_tensor.numpy())

AttributeError: module 'tensorflow_datasets.core.features' has no attribute 'text'

问题解决

这是因为一些方法已被弃用,换用tfds.deprecated.text.Tokenizer来创建tokenizer对象。

参考文献

github
tensorflow官网

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

TensorFlow-v2.9

TensorFlow-v2.9

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值