首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >“AutoTrackable”对象在Python语言中不可调用

“AutoTrackable”对象在Python语言中不可调用
EN

Stack Overflow用户
提问于 2019-12-25 01:32:07
回答 1查看 7.8K关注 0票数 12

我的tensorflow版本是2.0

tensorflow_hub版本为0.7

python版本为3.7

我有这些代码

代码语言:javascript
运行
复制
import tensorflow as tf
import tensorflow_hub as hub
import summarizer_data_utils

specials = ["<EOS>", "<SOS>","<PAD>","<UNK>"]
word2ind, ind2word,  missing_words = summarizer_data_utils.create_word_inds_dicts(words_counted,
                                                                       specials = specials)

#embed = hub.Module("https://tfhub.dev/google/nnlm-en-dim128/1")
embed = hub.load("https://tfhub.dev/google/Wiki-words-250/1")
emb = embed([key for key in word2ind.keys()])

我得到了这个错误

代码语言:javascript
运行
复制
Processing Time:  32.69666647911072
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-aefe0bf334ec> in <module>
     84 #embed = hub.Module("https://tfhub.dev/google/nnlm-en-dim128/1")
     85 embed = hub.load("https://tfhub.dev/google/Wiki-words-250/1")
---> 86 emb = embed([key for key in word2ind.keys()])
     87 
     88 with tf.Session() as sess:

TypeError: 'AutoTrackable' object is not callable

我该怎么解决呢?

编辑:我找到了我的解决方案。我只需要改变

代码语言:javascript
运行
复制
https://tfhub.dev/google/Wiki-words-250/1

代码语言:javascript
运行
复制
https://tfhub.dev/google/Wiki-words-250/2
EN

回答 1

Stack Overflow用户

发布于 2020-05-16 06:28:40

这是TensorFlow中常见问题的一部分:https://www.tensorflow.org/hub/common_issues

解决方案是提取您需要的签名,例如:

代码语言:javascript
运行
复制
embed = hub.load('https://tfhub.dev/google/nnlm-en-dim128/1')
embed.signatures['default'](['my text', 'batch'])
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59471873

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档