作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个模型,我用管道注册了它:
register_step = PythonScriptStep(name = "Register Model",
source_directory = training_folder,
script_name = "register_model.py",
arguments = ['--model_folder', model_folder],
inputs=[model_folder],
compute_target = pipeline_cluster,
runconfig = pipeline_run_config,
allow_reuse = True)
import argparse
import joblib
from azureml.core import Workspace, Model, Run
# Get parameters
parser = argparse.ArgumentParser()
parser.add_argument('--model_folder', type=str, dest='model_folder', default="model", help='model location')
args = parser.parse_args()
model_folder = args.model_folder
# Get the experiment run context
run = Run.get_context()
# Load the model
print("Loading model from " + model_folder)
model_file = model_folder + "/model.pkl"
model = joblib.load(model_file)
Model.register(workspace=run.experiment.workspace,
model_path = model_file,
model_name = 'model',
tags={'Training context':'Pipeline'})
run.complete()
from azureml.core import Model
for model in Model.list(ws):
print(model.name, 'version:', model.version)
for tag_name in model.tags:
tag = model.tags[tag_name]
print ('\t',tag_name, ':', tag)
for prop_name in model.properties:
prop = model.properties[prop_name]
print ('\t',prop_name, ':', prop)
print('\n')
model_path = Model.get_model_path(
model_name="model", version=1)
ModelNotFoundException Traceback (most recent call last)
/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/core/model.py in get_model_path(model_name, version, _workspace)
751 try:
--> 752 return Model._get_model_path_local(model_name, version)
753 except ModelNotFoundException as ee:
/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/core/model.py in _get_model_path_local(model_name, version)
783 if not os.path.exists(candidate_model_path):
--> 784 return Model._get_model_path_local_from_root(model_name)
785 else:
/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/core/model.py in _get_model_path_local_from_root(model_name)
826 raise ModelNotFoundException("Model not found in cache or in root at ./{}. For more info,"
--> 827 "set logging level to DEBUG.".format(candidate_model_path))
828
ModelNotFoundException: ModelNotFoundException:
Message: Model not found in cache or in root at ./model. For more info,set logging level to DEBUG.
InnerException None
ErrorResponse
{
"error": {
"message": "Model not found in cache or in root at ./model. For more info,set logging level to DEBUG."
}
}
During handling of the above exception, another exception occurred:
WebserviceException Traceback (most recent call last)
<ipython-input-6-27e8df94d66f> in <module>
1 model_path = Model.get_model_path(
----> 2 model_name="model", version=1)
/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/core/model.py in get_model_path(model_name, version, _workspace)
756 module_logger.debug("Getting model from remote")
757 return Model._get_model_path_remote(model_name, version, active_workspace)
--> 758 raise WebserviceException(ee.message, logger=module_logger)
759 else:
760 if active_workspace is not None:
WebserviceException: WebserviceException:
Message: Model not found in cache or in root at ./model. For more info,set logging level to DEBUG.
InnerException None
ErrorResponse
{
"error": {
"message": "Model not found in cache or in root at ./model. For more info,set logging level to DEBUG."
}
}
最佳答案
#Assume model_name is the variable containing name of your model
model_name = 'model'
ws = Run.get_context().experiment.workspace
model_obj = Model(ws, model_name )
model_path = model_obj.download(exist_ok = True)
model = joblib.load(model_path)
关于python - Model.get_model_path(model_name ="model") 抛出错误 : Model not found in cache or in root at,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60841319/
我有一个模型,我用管道注册了它: register_step = PythonScriptStep(name = "Register Model",
我是一名优秀的程序员,十分优秀!