{ "cells": [ { "cell_type": "markdown", "id": "white-electron", "metadata": {}, "source": [ "## Connect and Manage an Exist Experiment" ] }, { "cell_type": "markdown", "id": "recent-italic", "metadata": {}, "source": [ "### 1. Connect Experiment" ] }, { "cell_type": "code", "execution_count": 1, "id": "statistical-repair", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[2021-02-25 07:50:38] Tuner not set, wait for connect...\n", "[2021-02-25 07:50:38] Connect to port 8080 success, experiment id is IF0JnfLE, status is RUNNING.\n" ] } ], "source": [ "from nni.experiment import Experiment\n", "experiment = Experiment.connect(8080)" ] }, { "cell_type": "markdown", "id": "defensive-scratch", "metadata": {}, "source": [ "### 2. Experiment View & Control" ] }, { "cell_type": "code", "execution_count": 2, "id": "independent-touch", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'id': 'IF0JnfLE',\n", " 'revision': 6,\n", " 'execDuration': 28,\n", " 'logDir': '/home/ningshang/nni-experiments/IF0JnfLE',\n", " 'nextSequenceId': 2,\n", " 'params': {'authorName': 'default',\n", " 'experimentName': 'example_sklearn-classification',\n", " 'trialConcurrency': 1,\n", " 'maxExecDuration': 3600,\n", " 'maxTrialNum': 5,\n", " 'searchSpace': '{\"C\": {\"_type\": \"uniform\", \"_value\": [0.1, 1]}, \"kernel\": {\"_type\": \"choice\", \"_value\": [\"linear\", \"rbf\", \"poly\", \"sigmoid\"]}, \"degree\": {\"_type\": \"choice\", \"_value\": [1, 2, 3, 4]}, \"gamma\": {\"_type\": \"uniform\", \"_value\": [0.01, 0.1]}, \"coef0\": {\"_type\": \"uniform\", \"_value\": [0.01, 0.1]}}',\n", " 'trainingServicePlatform': 'local',\n", " 'tuner': {'builtinTunerName': 'TPE',\n", " 'classArgs': {'optimize_mode': 'maximize'},\n", " 'checkpointDir': '/home/ningshang/nni-experiments/IF0JnfLE/checkpoint'},\n", " 'versionCheck': True,\n", " 'clusterMetaData': [{'key': 'trial_config',\n", " 'value': {'command': 'python3 main.py',\n", " 'codeDir': '/home/ningshang/nni/examples/trials/sklearn/classification/.',\n", " 'gpuNum': 0}}]},\n", " 'startTime': 1614239412494}" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "experiment.get_experiment_profile()" ] }, { "cell_type": "code", "execution_count": 3, "id": "printable-bookmark", "metadata": {}, "outputs": [], "source": [ "experiment.update_max_trial_number(10)" ] }, { "cell_type": "code", "execution_count": 4, "id": "marine-serial", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'id': 'IF0JnfLE',\n", " 'revision': 8,\n", " 'execDuration': 32,\n", " 'logDir': '/home/ningshang/nni-experiments/IF0JnfLE',\n", " 'nextSequenceId': 2,\n", " 'params': {'authorName': 'default',\n", " 'experimentName': 'example_sklearn-classification',\n", " 'trialConcurrency': 1,\n", " 'maxExecDuration': 3600,\n", " 'maxTrialNum': 10,\n", " 'searchSpace': '{\"C\": {\"_type\": \"uniform\", \"_value\": [0.1, 1]}, \"kernel\": {\"_type\": \"choice\", \"_value\": [\"linear\", \"rbf\", \"poly\", \"sigmoid\"]}, \"degree\": {\"_type\": \"choice\", \"_value\": [1, 2, 3, 4]}, \"gamma\": {\"_type\": \"uniform\", \"_value\": [0.01, 0.1]}, \"coef0\": {\"_type\": \"uniform\", \"_value\": [0.01, 0.1]}}',\n", " 'trainingServicePlatform': 'local',\n", " 'tuner': {'builtinTunerName': 'TPE',\n", " 'classArgs': {'optimize_mode': 'maximize'},\n", " 'checkpointDir': '/home/ningshang/nni-experiments/IF0JnfLE/checkpoint'},\n", " 'versionCheck': True,\n", " 'clusterMetaData': [{'key': 'trial_config',\n", " 'value': {'command': 'python3 main.py',\n", " 'codeDir': '/home/ningshang/nni/examples/trials/sklearn/classification/.',\n", " 'gpuNum': 0}}]},\n", " 'startTime': 1614239412494}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "experiment.get_experiment_profile()" ] }, { "cell_type": "markdown", "id": "opened-lounge", "metadata": {}, "source": [ "### 3. Stop Experiment" ] }, { "cell_type": "code", "execution_count": 5, "id": "emotional-machinery", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[2021-02-25 07:50:49] Stopping experiment, please wait...\n", "[2021-02-25 07:50:49] Experiment stopped\n" ] } ], "source": [ "experiment.stop()" ] } ], "metadata": { "kernelspec": { "display_name": "nni-dev", "language": "python", "name": "nni-dev" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.9" } }, "nbformat": 4, "nbformat_minor": 5 }