Tensorflow Hub:导入模型时卡住
Tensorflow Hub : Stuck while importing a model
尝试使用此代码将一些模型导入 Tensorflow Hub:
import tensorflow as tf
import tensorflow_hub as hub
elmo_model = hub.Module('https://tfhub.dev/google/elmo/2', trainable=True)
让我的笔记本卡住了。卡住之前出现的唯一日志行是:
INFO:tensorflow:Using /tmp/tfhub_modules to cache modules.
如何解除它并允许我从 Tensorflow Hub 导入模型?
这只是权限问题:我无法访问 Tensorflow Hub 存储模型的默认目录 (/tmp/tfhub_modules
)。
为了解决这个问题,我只是选择一个目录来存储我可以访问的模型:
import os
import tensorflow as tf
import tensorflow_hub as hub
os.environ['TFHUB_CACHE_DIR'] = '/home/user/workspace/tf_cache'
elmo_model = hub.Module('https://tfhub.dev/google/elmo/2', trainable=True)
尝试使用此代码将一些模型导入 Tensorflow Hub:
import tensorflow as tf
import tensorflow_hub as hub
elmo_model = hub.Module('https://tfhub.dev/google/elmo/2', trainable=True)
让我的笔记本卡住了。卡住之前出现的唯一日志行是:
INFO:tensorflow:Using /tmp/tfhub_modules to cache modules.
如何解除它并允许我从 Tensorflow Hub 导入模型?
这只是权限问题:我无法访问 Tensorflow Hub 存储模型的默认目录 (/tmp/tfhub_modules
)。
为了解决这个问题,我只是选择一个目录来存储我可以访问的模型:
import os
import tensorflow as tf
import tensorflow_hub as hub
os.environ['TFHUB_CACHE_DIR'] = '/home/user/workspace/tf_cache'
elmo_model = hub.Module('https://tfhub.dev/google/elmo/2', trainable=True)