使用 Tensorflow Hub 时范围变量出错
Error on Scope Variable While Using Tensorflow Hub
我正在使用 Colab 运行 一段文本分析代码。我想从 tensorflow_hub 得到 universal-sentence-encoder-large。
但是随时 运行 包含以下代码的块:
module = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3")
我收到这个错误:
RuntimeError: variable_scope module_8/ was unused but the
corresponding name_scope was already taken.
如果您知道如何修复此错误,我将不胜感激?
TF Hub USE-3 Module 不适用于 Tensorflow 2.0 版。
因此,如果您将版本从 2.0 更改为 1.15,它可以正常工作。
请找到下面提到的工作代码:
!pip install tensorflow==1.15
!pip install "tensorflow_hub>=0.6.0"
!pip3 install tensorflow_text==1.15
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
import tensorflow_text
module = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3")
请同时找到 Google Colab 的 Github Gist。
在 google colab 中使用 tensorflow 2,你应该使用 hub.load(url) 而不是 hub.Module(url)
我正在使用 Colab 运行 一段文本分析代码。我想从 tensorflow_hub 得到 universal-sentence-encoder-large。 但是随时 运行 包含以下代码的块:
module = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3")
我收到这个错误:
RuntimeError: variable_scope module_8/ was unused but the
corresponding name_scope was already taken.
如果您知道如何修复此错误,我将不胜感激?
TF Hub USE-3 Module 不适用于 Tensorflow 2.0 版。
因此,如果您将版本从 2.0 更改为 1.15,它可以正常工作。
请找到下面提到的工作代码:
!pip install tensorflow==1.15
!pip install "tensorflow_hub>=0.6.0"
!pip3 install tensorflow_text==1.15
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
import tensorflow_text
module = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3")
请同时找到 Google Colab 的 Github Gist。
在 google colab 中使用 tensorflow 2,你应该使用 hub.load(url) 而不是 hub.Module(url)