快速入門:使用雲端式 Notebook 伺服器開始使用 Azure Machine LearningQuickstart: Use a cloud-based notebook server to get started with Azure Machine Learning

無需安裝。No install required. 以雲端中的受控筆記本伺服器開始使用 Azure Machine Learning 服務。Get started with Azure Machine Learning service using a managed notebook server in the cloud. 如果您想要改為將 SDK 安裝至自己的 Python 環境,請參閱快速入門:使用您自有的 Notebook 伺服器來開始使用 Azure Machine LearningIf you want to instead install the SDK into your own Python environment, see Quickstart: Use your own notebook server to get started with Azure Machine Learning.

本快速入門顯示您可以如何使用 Azure Machine Learning 服務工作區來追蹤您的機器學習實驗。This quickstart shows how you can use the Azure Machine Learning service workspace to keep track of your machine learning experiments. 您將會建立 Notebook VM (預覽),它是安全的雲端式 Azure 工作站,且提供 Jupyter Notebook 伺服器、JupyterLab 和準備就緒的 ML 環境。You will create a notebook VM (Preview), a secure, cloud-based Azure workstation that provides a Jupyter notebook server, JupyterLab, and a fully prepared ML environment. 您接著會在此 VM 上執行將值記錄到工作區中的 Python Notebook。You then run a Python notebook on this VM that log values into the workspace.

在本快速入門中,您會執行下列動作:In this quickstart, you take the following actions:

  • 建立工作區Create a workspace
  • 在您的工作區中建立 Notebook VM。Create a notebook VM in your workspace.
  • 啟動 Jupyter Web 介面。Launch the Jupyter web interface.
  • 開啟包含程式碼的 Notebook,以估計每個反覆項目的 pi 和記錄錯誤。Open a notebook that contains code to estimate pi and logs errors at each iteration.
  • 執行 Notebook。Run the notebook.
  • 在工作區中檢視記錄錯誤的值。View the logged error values in your workspace. 這個範例示範工作區如何協助您追蹤指令碼中所產生的資訊。This example shows how the workspace can help you keep track of information generated in a script.

如果您沒有 Azure 訂用帳戶,請在開始前先建立一個免費帳戶。If you don’t have an Azure subscription, create a free account before you begin. 立即試用免費或付費版本的 Azure Machine Learning 服務Try the free or paid version of Azure Machine Learning service today.

建立工作區Create a workspace

如果您有 Azure Machine Learning 服務工作區,請跳至下一節If you have an Azure Machine Learning service workspace, skip to the next section. 否則,請建立此工作區。Otherwise, create one now.

  1. 使用您所使用之 Azure 訂用帳戶的認證來登入 Azure 入口網站Sign in to the Azure portal by using the credentials for the Azure subscription you use.

    Azure 入口網站

  2. 在入口網站的左上角,選取 [建立資源] 。In the upper-left corner of the portal, select Create a resource.

    在 Azure 入口網站中建立資源

  3. 在搜尋列中輸入 Machine LearningIn the search bar, enter Machine Learning. 選取 Machine Learning Service 工作區的搜尋結果。Select the Machine Learning service workspace search result.

    搜尋工作區

  4. 在 [ML 服務工作區] 窗格中選取 [建立] 來開始操作。In the ML service workspace pane, select Create to begin.

    建立按鈕

  5. 在 [ML 服務工作區] 窗格中,設定您的工作區。In the ML service workspace pane, configure your workspace.

    欄位Field 說明Description
    工作區名稱Workspace name 輸入可識別您工作區的唯一名稱。Enter a unique name that identifies your workspace. 在此範例中,我們使用 docs-wsIn this example, we use docs-ws. 名稱必須是整個資源群組中唯一的。Names must be unique across the resource group. 請使用可輕鬆回想並且與其他人建立的工作區有所區別的名稱。Use a name that's easy to recall and differentiate from workspaces created by others.
    訂用帳戶Subscription 選取您要使用的 Azure 訂用帳戶。Select the Azure subscription that you want to use.
    資源群組Resource group 在您的訂用帳戶中使用現有的資源群組,或輸入名稱來建立新的資源群組。Use an existing resource group in your subscription, or enter a name to create a new resource group. 資源群組會保留 Azure 方案的相關資源。A resource group holds related resources for an Azure solution. 在此範例中,我們使用 docs-amlIn this example, we use docs-aml.
    位置Location 選取最接近您的使用者與資料資源的位置。Select the location closest to your users and the data resources. 此位置是建立工作區的所在位置。This location is where the workspace is created.

    建立工作區

  6. 若要開始執行建立程序,請選取 [檢閱 + 建立] 。To start the creation process, select Review + Create.

    建立

  7. 檢閱工作區設定。Review your workspace configuration. 如果正確,請選取 [建立] 。If it is correct, select Create. 建立工作區可能需要一些時間。It can take a few moments to create the workspace.

    建立

  8. 若要檢查部署狀態,請選取工具列上的通知圖示 (鈴鐺) 。To check on the status of the deployment, select the Notifications icon, bell, on the toolbar.

  9. 程序完成後,會出現部署成功訊息。When the process is finished, a deployment success message appears. 它也會出現在通知區段中。It's also present in the notifications section. 若要檢視新的工作區,選取 [前往資源] 。To view the new workspace, select Go to resource.

    工作區建立狀態

建立 Notebook VMCreate a notebook VM

從您的工作區建立雲端資源,以開始使用 Jupyter Notebook。From your workspace, you create a cloud resource to get started using Jupyter notebooks. 這項資源為您提供雲端式平台,其已預先設定執行 Azure Machine Learning 服務所需的一切。This resource gives you a cloud-based platform pre-configured with everything you need to run Azure Machine Learning service.

  1. Azure 入口網站中開啟工作區。Open your workspace in the Azure portal. 如果您不確定如何在入口網站中找出您的工作區,請參閱如何尋找您的工作區If you're not sure how to locate your workspace in the portal, see how to find your workspace.

  2. 在 Azure 入口網站中您的工作區頁面上,選取左側的 [Notebook VM] 。On your workspace page in the Azure portal, select Notebook VMs on the left.

  3. 選取 [+新增] 以建立 Notebook VM。Select +New to create a notebook VM.

    選取新的 VM

  4. 為您的 VM 提供名稱。Provide a name for your VM. 然後選取 [建立] 。Then select Create.

    注意

    Notebook 虛擬機器名稱長度必須介於 2 到 16 個字元之間。Your Notebook VM name must be between 2 to 16 characters. 有效字元包含字母、數字及 - 字元。Valid characters are letters, digits, and the - character. 名稱在 Azure 訂用帳戶中必須是唯一的。The name must also be unique across your Azure subscription.

    建立新的 VM

  5. 等待約 4-5 分鐘,直到狀態變更為執行中Wait approximately 4-5 minutes, until the status changes to Running.

啟動 Jupyter Web 介面Launch Jupyter web interface

在您的 VM 執行之後,使用 [Notebook VM] 區段來啟動 Jupyter Web 介面。After your VM is running, use the Notebook VMs section to launch the Jupyter web interface.

  1. 在您 VM 的 [URI] 資料行中選取 [Jupyter] 。Select Jupyter in the URI column for your VM.

    啟動 Jupyter Notebook 伺服器

    此連結會啟動 Notebook 伺服器,並且在新的瀏覽器索引標籤中開啟 Jupyter Notebook 網頁。此連結只適用於建立 VM 的人員。The link starts your notebook server and opens the Jupyter notebook webpage in a new browser tab. This link will only work for the person who creates the VM.

  2. 在 Jupyter Notebook 網頁上,上方的資料夾名稱即為您的使用者名稱。On the Jupyter notebook webpage, the top foldername is your username. 選取此資料夾。Select this folder.

  3. 範例資料夾名稱包含版本號碼,例如 範例 1.0.33.1The samples foldername includes a version number, for example samples-1.0.33.1. 選取範例資料夾。Select the samples folder.

  4. 選取快速入門 Notebook。Select the quickstart notebook.

執行 NotebookRun the notebook

執行 Notebook,以評估 pi 並將錯誤記錄至您的工作區。Run a notebook that estimates pi and logs the error to your workspace.

  1. 選取 01.run-experiment.ipynb 以開啟 Notebook。Select 01.run-experiment.ipynb to open the notebook.

  2. 在第一個程式碼儲存格中按一下,然後選取 [執行] 。Click into the first code cell and select Run.

    注意

    程式碼儲存格的前面有方括號。Code cells have brackets before them. 如果方括號是空的 ( [ ] ),則尚未執行程式碼。If the brackets are empty ([ ]), the code has not been run. 執行程式碼時,您會看到一個星號 ( [*] )。While the code is running, you see an asterisk([*]). 程式碼完成後,隨即出現一個數字 [1]After the code completes, a number [1] appears. 此數字會告訴您儲存格的執行順序。The number tells you the order in which the cells ran.

    使用 Shift-Enter 作為執行儲存格的快速鍵。Use Shift-Enter as a shortcut to run a cell.

    執行第一個程式碼儲存格

  3. 執行第二個程式碼儲存格。Run the second code cell. 如果您看到進行驗證的指示,請複製程式碼並遵循連結進行登入。If you see instructions to authenticate, copy the code and follow the link to sign in. 在您登入後,您的瀏覽器會記住這項設定。Once you sign in, your browser will remember this setting.

    驗證

  4. 完成時,儲存格編號 [2] 隨即出現。When complete, the cell number [2] appears. 如果您必須登入,則會看到成功的驗證狀態訊息。If you had to sign in, you will see a successful authentication status message. 如果您不必登入,則不會看到此儲存格的任何輸出,只會出現顯示儲存格執行成功的數字。If you didn't have to sign in, you won't see any output for this cell, only the number appears to show that the cell ran successfully.

    成功訊息

  5. 執行剩餘的程式碼儲存格。Run the rest of the code cells. 當每個資料格執行完成時,您會看到其資料格編號出現。As each cell finishes running, you will see its cell number appear. 只有最後一個資料格會顯示任何其他輸出。Only the last cell displays any other output.

    在最大程式碼儲存格中,您會看到 run.log 使用於多個地方。In the largest code cell, you see run.log used in multiple places. 每個 run.log 會將其值新增至您的工作區。Each run.log adds its value to your workspace.

檢視記錄的值View logged values

  1. run 資料格的輸出包含連回 Azure 入口網站的連結,可讓您在工作區中檢視實驗結果。The output from the run cell contains a link back to the Azure portal to view the experiment results in your workspace.

    檢視實驗

  2. 按一下 [連結至 Azure 入口網站] ,在您的工作區中檢視執行的相關資訊。Click the Link to Azure portal to view information about the run in your workspace. 此連結會在 Azure 入口網站中開啟您的工作區。This link opens your workspace in the Azure portal.

  3. 您看到的記錄值繪圖已自動建立於工作區中。The plots of logged values you see were automatically created in the workspace. 每當您使用相同的名稱參數記錄多個值時,系統就會自動為您產生繪圖。Whenever you log multiple values with the same name parameter, a plot is automatically generated for you.

    檢視歷程記錄

用於大致估計 pi 的程式碼會使用隨機值,因此您的圖會顯示不同的值。Because the code to approximate pi uses random values, your plots will show different values.

清除資源Clean up resources

停止 Notebook VMStop the notebook VM

當您不使用 Notebook VM 來降低成本時,請將它停止。Stop the notebook VM when you are not using it to reduce cost.

  1. 在您的工作區中,選取 [Notebook VM] 。In your workspace, select Notebook VMs.

    停止 VM 伺服器

  2. 從清單中選取 VM。From the list, select the VM.

  3. 選取 [停止] 。Select Stop.

  4. 當您準備好再次使用伺服器時,請選取 [啟動] 。When you're ready to use the server again, select Start.

刪除所有內容Delete everything

重要

您所建立的資源可用來作為其他 Azure Machine Learning 服務教學課程和操作說明文章的先決條件。The resources you created can be used as prerequisites to other Azure Machine Learning service tutorials and how-to articles.

如果您不打算使用您建立的資源,請刪除它們,以免產生任何費用:If you don't plan to use the resources you created, delete them, so you don't incur any charges:

  1. 在 Azure 入口網站中,選取最左邊的 [資源群組] 。In the Azure portal, select Resource groups on the far left.

    在 Azure 入口網站中刪除

  2. 在清單中,選取您所建立的資源群組。From the list, select the resource group you created.

  3. 選取 [刪除資源群組] 。Select Delete resource group.

  4. 輸入資源群組名稱。Enter the resource group name. 然後選取 [刪除] 。Then select Delete.

您也可以保留資源群組,但刪除單一工作區。You can also keep the resource group but delete a single workspace. 顯示工作區屬性,然後選取 [刪除] 。Display the workspace properties and select Delete.

後續步驟Next steps

在本快速入門中,您已完成下列工作:In this quickstart, you completed these tasks:

  • 建立工作區Create a workspace
  • 建立 Notebook 虛擬機器。Create a notebook VM.
  • 啟動 Jupyter Web 介面。Launch the Jupyter web interface.
  • 開啟包含程式碼的 Notebook,以估計每個反覆項目的 pi 和記錄錯誤。Open a notebook that contains code to estimate pi and logs errors at each iteration.
  • 執行 Notebook。Run the notebook.
  • 在工作區中檢視記錄錯誤的值。View the logged error values in your workspace. 這個範例示範工作區如何協助您追蹤指令碼中所產生的資訊。This example shows how the workspace can help you keep track of information generated in a script.

在 Jupyter Notebook 網頁的範例資料夾中瀏覽其他 Notebook,進一步了解 Azure Machine Learning 服務。On the Jupyter Notebook webpage, browse through other notebooks in the samples folder to learn more about Azure Machine Learning service.

如需深入的工作流程體驗,請按照 Machine Learning 教學課程來定型和部署模型:For an in-depth workflow experience, follow Machine Learning tutorials to train and deploy a model: