python注册表中缺少图操作

问题描述

我正在尝试从bertseq2seq/roberta24_bbc运行示例代码

import tensorflow.compat.v1 as tf
import tensorflow_hub as hub
import sentencepiece

text_generator = hub.Module(
    'https://tfhub.dev/google/bertseq2seq/roberta24_bbc/1')
input_documents = ['This is text from the first document.','This is text from the second document.']
output_summaries = text_generator(input_documents)
print(output_summaries)

我使用Python v3.7.4创建了一个虚拟环境,并按照网站上的说明安装了TFv1:

pip install "tensorflow>=1.15,<2.0"
pip install --upgrade tensorflow-hub 

但是当我执行时,出现以下错误

Exception has occurred: NotFoundError
Graph ops missing from the python registry ({'SentencepieceOp','SentencepieceDetokenizeOp','SentencepiecetokenizeOp'}) 
are also absent from the c++ registry.

关于如何解决它的任何想法?

更新:我的requirements.txt

absl-py==0.10.0
astor==0.8.1
astunparse==1.6.3
cachetools==4.1.1
certifi==2020.6.20
chardet==3.0.4
gast==0.2.2
google-auth==1.21.2
google-auth-oauthlib==0.4.1
google-pasta==0.2.0
grpcio==1.32.0
h5py==2.10.0
idna==2.10
importlib-Metadata==1.7.0
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
Markdown==3.2.2
mock==4.0.2
numpy==1.18.5
oauthlib==3.1.0
opt-einsum==3.3.0
protobuf==3.13.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
requests==2.24.0
requests-oauthlib==1.3.0
rsa==4.6
scipy==1.4.1
sentencepiece==0.1.92
six==1.15.0
tensorboard==1.15.0
tensorboard-plugin-wit==1.7.0
tensorflow==1.15.3
tensorflow-estimator==1.15.1
tensorflow-hub==0.9.0
tensorflow-text==1.15.1
termcolor==1.1.0
tf-sentencepiece==0.1.92
urllib3==1.25.10
Werkzeug==1.0.1
wrapt==1.12.1
zipp==3.1.0

解决方法

Sentencepiece操作已移至单独的软件包tf_sentencepiece

pip install tf_sentencepiece

如果无法完全正常运行,您可能还必须在脚本开始时手动将其导入。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...