Machine learning 从URL加载权重

Machine learning 从URL加载权重,machine-learning,keras,Machine Learning,Keras,我有CNN模型的权重文件(.h5)的URL。我想将该权重直接加载到Python文件中,并编译一个keras模型。这怎么办 有没有直接的方法,或者我应该下载权重文件并从磁盘加载它?有一个功能可以从URL下载权重并将其储存在~/.keras中/ 这是函数get_file from keras.utils.data_utils import get_file 例如: from keras.utils.data_utils import get_file weights_path = get_file

我有CNN模型的权重文件(
.h5
)的URL。我想将该权重直接加载到Python文件中,并编译一个keras模型。这怎么办


有没有直接的方法,或者我应该下载权重文件并从磁盘加载它?

有一个功能可以从URL下载权重并将其储存在~/.keras中/

这是函数get_file

from keras.utils.data_utils import get_file
例如:

from keras.utils.data_utils import get_file
weights_path = get_file(
            'the name under the model will be saved',
            'YOUR URL')
model.load_weights(weights_path)
它返回保存权重的路径。 然后你可以使用负载重量。
但在所有情况下,权重都将保存在您的计算机上。

我使用请求库加载了权重。我现在将尝试keras get_文件。