Tensorflow Hub:导入模型时卡住

Ast*_*iul 4 python tensorflow jupyter-notebook tensorflow-hub

尝试使用Tensorflow Hub使用以下代码导入一些模型:

import tensorflow as tf
import tensorflow_hub as hub

elmo_model = hub.Module('https://tfhub.dev/google/elmo/2', trainable=True)
Run Code Online (Sandbox Code Playgroud)

使我的笔记本卡住了。卡住之前出现的唯一日志行是:

INFO:tensorflow:使用/ tmp / tfhub_modules缓存模块。

如何取消粘贴并允许我从Tensorflow Hub导入模型?

Ast*_*iul 5

这仅仅是关于特权的:我无法访问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)
Run Code Online (Sandbox Code Playgroud)