gpt4 book ai didi

python - “AutoTrackable”对象在 Python 中不可调用

转载 作者:行者123 更新时间:2023-12-03 15:47:28 41 4
gpt4 key购买 nike

我的 tensorflow 版本是 2.0

tensorflow_hub 版本是 0.7

python版本是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

我该如何解决?

编辑:我找到了我的解决方案。我只需要改变
https://tfhub.dev/google/Wiki-words-250/1


https://tfhub.dev/google/Wiki-words-250/2

最佳答案

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

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

embed = hub.load('https://tfhub.dev/google/nnlm-en-dim128/1')
embed.signatures['default'](['my text', 'batch'])

关于python - “AutoTrackable”对象在 Python 中不可调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59471873/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com