我想像这样将创建的图表记录到我的工作区中:
from azureml.core import Runfrom matplotlib import pyplot as pltrun = 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 whatlocation = file.tell()
我可以将变量记录到Azure ML中。如果我在没有Azure ML的情况下本地运行脚本,我可以正确地看到图表。我如何将我的图表记录到我的Azure实验中?
回答:
我找到了答案。为了将plt保存到Azure ML中,你必须指定哪个是图表,而不仅仅是将其作为第二个参数发送。
...run.log_image('Plot', plot=plt)