【发布时间】:2020-04-29 00:26:51
【问题描述】:
我在为 NLP 任务加载预训练模块时遇到问题,问题是由于我想的 tf 迁移。 Tensorflow 网站表示,如果正确给出签名变量,问题可能会得到解决。你能帮我更正这段代码吗?
TypeError: 'AutoTrackable' 对象不可调用
[代码]
import tensorflow_hub as hub
# enabling the pretrained model for trainig our custom model using tensorflow hub
module_url = "https://tfhub.dev/google/universal-sentence-encoder-large/3"
embed = hub.load(module_url)
# creating a method for embedding and will using method for every input layer
def UniversalEmbedding(x):
return embed(tf.squeeze(tf.cast(x, tf.string)), signature='default', as_dict=True)["default"]
【问题讨论】:
-
我能够在 Google Colab 中运行它而没有任何错误,并且在两个版本的 tensorflow 中运行良好 - %tensorflow_version 1.x 和 %tensorflow_version 2.x。您使用的是哪个 IDE? TensorFlow 版本呢?
标签: python tensorflow nlp tensorflow2.0 pre-trained-model