如何用azure ml记录图?

问题描述 投票:0回答:1

我想将创建的绘图记录到我的工作区,如下所示:

from azureml.core import Run
from matplotlib import pyplot as plt

run = Run.get_context()
Foo = [1,2,3,4]
Bar = [4,3,2,1]

plt.title('Foo vs Bar')
plt.plot(Foo, label='Foo')
plt.plot(Bar, '-r', label='Bar')

run.log_image('Plot', plt)

但是我收到以下错误:

"type": "AttributeError",
"message": "module 'matplotlib.pyplot' has no attribute 'tell'",

当它试图计算时会发生这种情况:

File "/usr/lib/python3.6/imghdr.py", line 19, in what
location = file.tell()

我可以将变量记录到azureml。如果我在没有azureml的情况下在本地运行我的脚本,我可以正确地看到这些图。如何将我的情节记录到我的天蓝实验中?

python azure matplotlib machine-learning hdinsight
1个回答
0
投票

我找到了答案。为了将plt保存到azureml中,您必须指定哪个是绘图,而不是仅将其作为第二个参数发送。

...
run.log_image('Plot', plot=plt)
© www.soinside.com 2019 - 2024. All rights reserved.