首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有数据存储引用的反洗钱ScriptRunConfig

带有数据存储引用的反洗钱ScriptRunConfig
EN

Stack Overflow用户
提问于 2019-09-19 21:48:40
回答 2查看 1.6K关注 0票数 2

当尝试运行ScriptRunConfig时,请使用:

代码语言:javascript
复制
src = ScriptRunConfig(source_directory=project_folder, 
                      script='train.py', 
                      arguments=['--input-data-dir', ds.as_mount(),
                                 '--reg', '0.99'],
                      run_config=run_config) 
run = experiment.submit(config=src)

当我提交这份工作时,它不起作用,并与此断断续续:

代码语言:javascript
复制
... lots of things... and then
TypeError: Object of type 'DataReference' is not JSON serializable

不过,如果我用估计器运行它,它就能工作。其中一个不同之处在于,对于ScriptRunConfig,我们使用一个列表作为参数,而另一个是字典。

谢谢你的指点!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-09-20 02:14:46

能够在DataReference中使用ScriptRunConfig比只使用ds.as_mount()要复杂一些。您将需要将其转换为arguments中的字符串,然后使用从ds创建的DataReferenceConfiguration更新RunConfigurationdata_references部分。

如果您只是从输入位置读取,而不对其进行任何写入,请查看Dataset。它允许你做你正在做的事情而不做任何额外的事情。这里是一个例子笔记本,它在行动中显示这一点。

下面是笔记本的一个简短版本。

代码语言:javascript
复制
from azureml.core import Dataset

# more imports and code

ds = Datastore(workspace, 'mydatastore')
dataset = Dataset.File.from_files(path=(ds, 'path/to/input-data/within-datastore'))

src = ScriptRunConfig(source_directory=project_folder, 
                      script='train.py', 
                      arguments=['--input-data-dir', dataset.as_named_input('input').as_mount(),
                                 '--reg', '0.99'],
                      run_config=run_config) 
run = experiment.submit(config=src)
票数 4
EN

Stack Overflow用户

发布于 2021-01-14 16:44:55

您可以在正式文档中看到此链接how-to-migrate-from-estimators-to-scriptrunconfig

ScriptRunConfig中使用DataReference的核心代码是

代码语言:javascript
复制
# if you want to pass a DataReference object, such as the below:
datastore = ws.get_default_datastore()
data_ref = datastore.path('./foo').as_mount()

src = ScriptRunConfig(source_directory='.',
                      script='train.py',
                      arguments=['--data-folder', str(data_ref)], # cast the DataReference object to str
                      compute_target=compute_target,
                      environment=pytorch_env)
src.run_config.data_references = {data_ref.data_reference_name: data_ref.to_config()} # set a dict of the DataReference(s) you want to the `data_references` attribute of the ScriptRunConfig's underlying RunConfiguration object.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58019308

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档