简体   繁体   English

可在Azure ML中操作自定义R模型而无需在每次Web服务调用中加载它

[英]Operationalize custom R model in Azure ML without loading it on every call of web service

I am trying to serve an R model as a web service in Azure ML. 我正在尝试将R模型用作Azure ML中的Web服务。

The model is trained locally and uses Xgboost and other packages. 该模型在本地进行训练,并使用Xgboost和其他软件包。 I have had issues submitting it directly from AzureML package due to size exceeding 130 MB. 由于大小超过130 MB,我无法直接从AzureML包提交它。 The workaround was to upload all the packages and the model as zip to Azure and source it from there. 解决方法是将所有程序包和模型以zip格式上传到Azure并从那里获取资源。

The current issue is that the model is loaded from a zip file by Azure ML EVERY time the service is called making the response time very slow (4.5 seconds). 当前的问题是,每次调用服务时,Azure ML都会从zip文件中加载模型,这会使响应时间非常慢(4.5秒)。 How do I restructure the code so that the model is loaded only once from the file. 如何重新组织代码,以便仅从文件中加载模型一次。 Thank you for your help. 谢谢您的帮助。

Here is how it looks in AzureML 这是AzureML中的外观 在此处输入图片说明 And here is what is inside Execute R script 这是Execute R脚本的内容 在此处输入图片说明

Here is a clever trick for running initialization steps only the first time and not on every subsequent call. 这是一个聪明的技巧 ,它只在第一次运行初始化步骤,而不是在每个后​​续调用中都运行。

My understanding is that you would wrap the first 3 statements (that is through line 11) of your script in the following if statement: 我的理解是,您将在以下if语句中包装脚本的前3条语句(即通过第11行):

if (!is.element("my_env", search()))

The if statement would also contain the initialization of the my_env variable as shown in the example used in that blog: if语句还将包含my_env变量的初始化,如该博客中使用的示例所示:

R优化示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM