gpt4 book ai didi

python-3.x - Azure Web 服务部署在本地如何工作?

转载 作者:行者123 更新时间:2023-12-03 02:58:30 26 4
gpt4 key购买 nike

Azure ML 提供用于数据集管理和模型部署的客户端库(例如用于 Python 的 azureml)。据我了解,自定义算法将被序列化为 Pickle 文件,但我不确定之后会发生什么。如果我有一个具有深度神经网络架构的自定义模型,并设置了一个用于训练的 Web 服务和另一个用于评分的 Web 服务,我是否仍然需要开发该模型的机器来运行 Web 服务?我在 azureml 文档中发现了这一点,这很有帮助:

If a function has no source file associated with it (for example, you're developing inside of a REPL environment) then the functions byte code is serialized. If the function refers to any global variables those will also be serialized using Pickle. In this mode all of the state which you're referring to needs to be already defined (e.g. your published function should come after any other functions you are calling).

If a function is saved on disk then the entire module the function is defined in will be serialized and re-executed on the server to get the function back. In this mode the entire contents of the file is serialized and the order of the function definitions don't matter.

如果函数使用 TensorFlow 或 Keras 等库怎么办?有人可以解释一下 Pickle 模型创建后会发生什么吗?

谢谢!

最佳答案

您需要获取 model.pkl 文件,将其压缩,然后将其作为新数据集上传到 Azure 机器学习工作室。然后添加 python 模块并将其连接到新生成的 zip。

您现在可以在 AML Studio 实验中使用它。要使用该模型,请在 python 模块中添加以下代码:

import pandas as pd
import sys
import pickle

def azureml_main(dataframe1 = None, dataframe2 = None):
sys.path.insert(0,".\Script Bundle")
model = pickle.load(open(".\Script Bundle\model.pkl", 'rb'))
pred = model.predict(dataframe1)
return pd.DataFrame([pred[0]]),

You may find this post useful

关于python-3.x - Azure Web 服务部署在本地如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51198775/

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