我正在尝试下载 Google 今年 7 月刚刚发布的新的预训练多语言通用句子编码器。我使用 Colab 按照在他们网站上找到的测试进行操作,效果很好,但是当我尝试在本地进行测试时,它在尝试下载时永远挂起(代码复制自 tf's site ):
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
import tf_sentencepiece
# Some texts of different lengths.
english_sentences = ["dog", "Puppies are nice.", "I enjoy taking long walks along the beach with my dog."]
italian_sentences = ["cane", "I cuccioli sono carini.", "Mi piace fare lunghe passeggiate lungo la spiaggia con il mio cane."]
japanese_sentences = ["犬", "子犬はいいです", "私は犬と一緒にビーチを散歩するのが好きです"]
#hangs here:
embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-multilingual/1")
我已经安装了所有依赖项和软件包。其他更简单的模型也可以工作(例如英语句子编码器),只有这个新模型才会发生。有任何想法吗?谢谢大家!
最佳答案
为任何感兴趣的人找到并解决了问题。这似乎是tensorflow 1.14和tf-sentencepiece 0.1.82.1之间的兼容性问题。要解决此问题,只需将 TensorFlow 1.14 降级到 1.13.1,如所述 here ,为我工作。
关于python - 使用tensorflow的多语言通用句子编码器时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57204177/