2024-05-23 22:48:58 发布
网友
亲爱的,我正在为MNIST数据集运行第一个Azure教程。在
上面写着实用工具.py应该与代码在同一个文件夹中。我试图在myconda环境中安装python实用程序,但这并没有解决问题。在使用了pip install utils之后,我宁愿让它变得更糟:-(
这可能很简单,但我卡住了。 您将如何在运行的笔记本上执行此操作:
我在运行azuresdk和python3.6的单独环境中使用Anaconda。在
根据您的描述,我认为MNIST数据集的第一个Azure教程是Tutorial: Train an image classification model with Azure Machine Learning service。在
您可以通过教程中的链接找到所有源代码,如下所示:here。在
Get the notebookFor your convenience, this tutorial is available as a Jupyter notebook. Run the tutorials/img-classification-part1-training.ipynb notebook either in Azure Notebooks or in your own Jupyter notebook server.
Get the notebook
For your convenience, this tutorial is available as a Jupyter notebook. Run the tutorials/img-classification-part1-training.ipynb notebook either in Azure Notebooks or in your own Jupyter notebook server.
tutorials/img-classification-part1-training.ipynb
这是^{}的源代码。在
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import gzip import numpy as np import struct # load compressed MNIST gz files and return numpy arrays def load_data(filename, label=False): with gzip.open(filename) as gz: struct.unpack('I', gz.read(4)) n_items = struct.unpack('>I', gz.read(4)) if not label: n_rows = struct.unpack('>I', gz.read(4))[0] n_cols = struct.unpack('>I', gz.read(4))[0] res = np.frombuffer(gz.read(n_items[0] * n_rows * n_cols), dtype=np.uint8) res = res.reshape(n_items[0], n_rows * n_cols) else: res = np.frombuffer(gz.read(n_items[0]), dtype=np.uint8) res = res.reshape(n_items[0], 1) return res # one-hot encode a 1-D array def one_hot_encode(array, num_of_classes): return np.eye(num_of_classes)[array.reshape(-1)]
如果你想将它导入到Azure Jupyter笔记本中,请参阅我下面的步骤。在
New
Blank File
utils.py
Enter
Edit File
Save File
import utils
所以# make sure utils.py is in the same directory as this code的意思是如下图所示。在
# make sure utils.py is in the same directory as this code
根据您的描述,我认为MNIST数据集的第一个Azure教程是Tutorial: Train an image classification model with Azure Machine Learning service。在
您可以通过教程中的链接找到所有源代码,如下所示:here。在
这是^{} 的源代码。在
如果你想将它导入到Azure Jupyter笔记本中,请参阅我下面的步骤。在
New
按钮并选择Blank File
。utils.py
,并按Enter
键。Edit File
。utils.py
的内容,然后单击Save File
。import utils
,它可以工作。所以
# make sure utils.py is in the same directory as this code
的意思是如下图所示。在相关问题 更多 >
编程相关推荐