本文介绍了"AutoTrackable"对象在Python中不可调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的tensorflow版本是2.0
My tensorflow version is 2.0
tensorflow_hub版本为0.7
tensorflow_hub version is 0.7
python版本是3.7
python version is 3.7
我有这些代码
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()])
我得到这个错误
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
我应该如何解决?
我找到了解决方案.我只需要更改
Edited: I have found my solution. I just need to change
https://tfhub.dev/google/Wiki-words-250/1
到
https://tfhub.dev/google/Wiki-words-250/2
推荐答案
这是TensorFlow中常见问题的一部分: https://www.tensorflow.org/hub/common_issues
This is part of the common issues in TensorFlow:https://www.tensorflow.org/hub/common_issues
解决方案是提取所需的签名,例如:
Solution is to extract the signature that you need, for example:
embed = hub.load('https://tfhub.dev/google/nnlm-en-dim128/1')
embed.signatures['default'](['my text', 'batch'])
这篇关于"AutoTrackable"对象在Python中不可调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!