This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add python api example and update doc (#3396)
- Loading branch information
Showing
9 changed files
with
933 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
{ | ||
"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 | ||
} |
Oops, something went wrong.