gpt4 book ai didi

python - tensorflow 集线器 : Stuck while importing a model

转载 作者:太空狗 更新时间:2023-10-30 02:52:33 25 4
gpt4 key购买 nike

尝试使用此代码通过 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)

关于python - tensorflow 集线器 : Stuck while importing a model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52940184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com