Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 加载联机托管的TensorFlow(.h5)模型_Python_Tensorflow - Fatal编程技术网

Python 加载联机托管的TensorFlow(.h5)模型

Python 加载联机托管的TensorFlow(.h5)模型,python,tensorflow,Python,Tensorflow,我正在尝试使用在线存储的链接(https://)加载.h5模型,但我从TensorFlow得到此错误: MODEL_PATH = 'http://<url>/<model_name>.h5' # I have replace the <tags> with actual URL and file name model = load_model(MODEL_PATH) 与.h5的链接非常好,因此与TensorFlow有关。有人能帮忙吗?虽然我想不出从URL直接

我正在尝试使用在线存储的链接(
https://
)加载.h5模型,但我从TensorFlow得到此错误:

MODEL_PATH = 'http://<url>/<model_name>.h5'
# I have replace the <tags> with actual URL and file name
model = load_model(MODEL_PATH)

与.h5的链接非常好,因此与TensorFlow有关。有人能帮忙吗?

虽然我想不出从URL直接加载模型的方法,但我使用了一个技巧,使用
urllib.request
包实现了类似的功能

import urllib.request

urllib.request.urlretrieve(
        'http://<url>/model.h5', 'model.h5')
注意:以上代码是针对Python 3编写的。如果您使用的是Python 2,请使用以下代码:

import urllib
urllib.urlretrieve('http://<url>/model.h5', 'model.h5')
导入urllib
urllib.urlretrieve('http:///model.h5','model.h5')
MODEL_PATH = './model.h5'
import urllib
urllib.urlretrieve('http://<url>/model.h5', 'model.h5')