Unverified Commit 97866505 authored by SparkSnail's avatar SparkSnail Committed by GitHub
Browse files

Merge pull request #115 from Microsoft/master

merge master
parents d91c980f b8e4918b
...@@ -22,6 +22,7 @@ hyperband_tuner.py ...@@ -22,6 +22,7 @@ hyperband_tuner.py
''' '''
from enum import Enum, unique from enum import Enum, unique
import sys
import math import math
import copy import copy
import logging import logging
...@@ -140,13 +141,6 @@ class Bracket(): ...@@ -140,13 +141,6 @@ class Bracket():
value: latest result with sequence number seq value: latest result with sequence number seq
''' '''
if parameter_id in self.configs_perf[i]: if parameter_id in self.configs_perf[i]:
# this should always be true if there is no retry in training service
_logger.debug('assertion: %d %d, %s %s\n',
self.configs_perf[i][parameter_id][0],
seq,
str(type(self.configs_perf[i][parameter_id][0])),
str(type(seq)))
# assert self.configs_perf[i][parameter_id][0] < seq
if self.configs_perf[i][parameter_id][0] < seq: if self.configs_perf[i][parameter_id][0] < seq:
self.configs_perf[i][parameter_id] = [seq, value] self.configs_perf[i][parameter_id] = [seq, value]
else: else:
...@@ -214,6 +208,14 @@ class Bracket(): ...@@ -214,6 +208,14 @@ class Bracket():
self.num_configs_to_run.append(len(hyper_configs)) self.num_configs_to_run.append(len(hyper_configs))
self.increase_i() self.increase_i()
def extract_scalar_reward(value, scalar_key='default'):
if isinstance(value, float) or isinstance(value, int):
reward = value
elif isinstance(value, dict) and scalar_key in value and isinstance(value[scalar_key], (float, int)):
reward = value[scalar_key]
else:
raise RuntimeError('Incorrect final result: the final result for %s should be float/int, or a dict which has a key named "default" whose value is float/int.' % str(self.__class__))
return reward
class Hyperband(MsgDispatcherBase): class Hyperband(MsgDispatcherBase):
''' '''
...@@ -345,12 +347,16 @@ class Hyperband(MsgDispatcherBase): ...@@ -345,12 +347,16 @@ class Hyperband(MsgDispatcherBase):
''' '''
data: it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'. data: it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'.
''' '''
value = extract_scalar_reward(data['value'])
bracket_id, i, _ = data['parameter_id'].split('_')
bracket_id = int(bracket_id)
if data['type'] == 'FINAL': if data['type'] == 'FINAL':
# sys.maxsize indicates this value is from FINAL metric data, because data['sequence'] from FINAL metric
# and PERIODICAL metric are independent, thus, not comparable.
self.brackets[bracket_id].set_config_perf(int(i), data['parameter_id'], sys.maxsize, value)
self.completed_hyper_configs.append(data) self.completed_hyper_configs.append(data)
elif data['type'] == 'PERIODICAL': elif data['type'] == 'PERIODICAL':
bracket_id, i, _ = data['parameter_id'].split('_') self.brackets[bracket_id].set_config_perf(int(i), data['parameter_id'], data['sequence'], value)
bracket_id = int(bracket_id)
self.brackets[bracket_id].set_config_perf(int(i), data['parameter_id'], data['sequence'], data['value'])
else: else:
raise ValueError('Data type not supported: {}'.format(data['type'])) raise ValueError('Data type not supported: {}'.format(data['type']))
......
...@@ -132,10 +132,15 @@ class MetisTuner(Tuner): ...@@ -132,10 +132,15 @@ class MetisTuner(Tuner):
self.x_types[idx] = 'range_continuous' self.x_types[idx] = 'range_continuous'
elif key_type == 'choice': elif key_type == 'choice':
self.x_bounds[idx] = key_range self.x_bounds[idx] = key_range
for key_value in key_range:
if not isinstance(key_value, (int, float)):
raise RuntimeError("Metis Tuner only support numerical choice.")
self.x_types[idx] = 'discrete_int' self.x_types[idx] = 'discrete_int'
else: else:
logger.info("Metis Tuner doesn't support this kind of variable.") logger.info("Metis Tuner doesn't support this kind of variable: " + str(key_type))
raise RuntimeError("Metis Tuner doesn't support this kind of variable.") raise RuntimeError("Metis Tuner doesn't support this kind of variable: " + str(key_type))
else: else:
logger.info("The format of search space is not a dict.") logger.info("The format of search space is not a dict.")
raise RuntimeError("The format of search space is not a dict.") raise RuntimeError("The format of search space is not a dict.")
......
...@@ -76,7 +76,7 @@ The tuner has a lot of different files, functions and classes. Here we will only ...@@ -76,7 +76,7 @@ The tuner has a lot of different files, functions and classes. Here we will only
## 4. The Network Representation Json Example ## 4. The Network Representation Json Example
Here is an example of the intermediate representation JSON file we defined, which is passed from the tuner to the trial in the architecture search procedure. The example is as follows. Here is an example of the intermediate representation JSON file we defined, which is passed from the tuner to the trial in the architecture search procedure. Users can call "json\_to\_graph()" function in trial code to build a pytorch model or keras model from this JSON file. The example is as follows.
```json ```json
{ {
...@@ -169,11 +169,11 @@ Here is an example of the intermediate representation JSON file we defined, whic ...@@ -169,11 +169,11 @@ Here is an example of the intermediate representation JSON file we defined, whic
} }
``` ```
The definition of each model is a JSON object(also you can consider the model as a DAG graph), where: The definition of each model is a JSON object(also you can consider the model as a [directed acyclic graph](https://en.wikipedia.org/wiki/Directed_acyclic_graph)), where:
- `input_shape` is a list of integers, which does not include the batch axis. - `input_shape` is a list of integers, which does not include the batch axis.
- `weighted` means whether the weights and biases in the neural network should be included in the graph. - `weighted` means whether the weights and biases in the neural network should be included in the graph.
- `operation_history` is the number of inputs the layer has. - `operation_history` is a list saving all the network morphism operations.
- `layer_id_to_input_node_ids` is a dictionary instance mapping from layer identifiers to their input nodes identifiers. - `layer_id_to_input_node_ids` is a dictionary instance mapping from layer identifiers to their input nodes identifiers.
- `layer_id_to_output_node_ids` is a dictionary instance mapping from layer identifiers to their output nodes identifiers - `layer_id_to_output_node_ids` is a dictionary instance mapping from layer identifiers to their output nodes identifiers
- `adj_list` is a two dimensional list. The adjacency list of the graph. The first dimension is identified by tensor identifiers. In each edge list, the elements are two-element tuples of (tensor identifier, layer identifier). - `adj_list` is a two dimensional list. The adjacency list of the graph. The first dimension is identified by tensor identifiers. In each edge list, the elements are two-element tuples of (tensor identifier, layer identifier).
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
font-family: 'Segoe'; font-family: 'Segoe';
color: #212121; color: #212121;
font-size: 14px; font-size: 14px;
background: #f2f2f2;
} }
.header{ .header{
...@@ -19,7 +20,6 @@ ...@@ -19,7 +20,6 @@
} }
.contentBox{ .contentBox{
width: 100%; width: 100%;
background: #f2f2f2;
} }
.content{ .content{
width: 86%; width: 86%;
......
import * as React from 'react'; import * as React from 'react';
import { Row, Button } from 'antd'; import { Row } from 'antd';
import { DOWNLOAD_IP } from '../../static/const'; import { DOWNLOAD_IP } from '../../static/const';
interface PaiTrialChildProps { interface PaiTrialChildProps {
...@@ -17,7 +17,7 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> { ...@@ -17,7 +17,7 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> {
} }
render() { render() {
const { logString, id, showLogModal, isdisLogbtn } = this.props; const { logString, id } = this.props;
return ( return (
<div> <div>
{ {
...@@ -35,16 +35,6 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> { ...@@ -35,16 +35,6 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> {
trial stdout trial stdout
</a> </a>
</Row> </Row>
<Row>
<Button
disabled={isdisLogbtn}
type="primary"
className="tableButton"
onClick={showLogModal.bind(this, id)}
>
View
</Button>
</Row>
</Row> </Row>
} }
</div> </div>
......
import * as React from 'react'; import * as React from 'react';
import { Row, Button } from 'antd'; import { Row } from 'antd';
import { DOWNLOAD_IP } from '../../static/const'; import { DOWNLOAD_IP } from '../../static/const';
import PaiTrialChild from './PaiTrialChild'; import PaiTrialChild from './PaiTrialChild';
...@@ -44,16 +44,6 @@ class PaitrialLog extends React.Component<PaitrialLogProps, {}> { ...@@ -44,16 +44,6 @@ class PaitrialLog extends React.Component<PaitrialLogProps, {}> {
</a> </a>
<a target="_blank" href={logStr.split(',')[1]}>hdfsLog</a> <a target="_blank" href={logStr.split(',')[1]}>hdfsLog</a>
</Row> </Row>
<Row>
<Button
disabled={isdisLogbutton}
type="primary"
className="tableButton"
onClick={showLogModal.bind(this, id)}
>
View
</Button>
</Row>
</Row> </Row>
: :
<PaiTrialChild <PaiTrialChild
......
...@@ -201,7 +201,8 @@ class SuccessTable extends React.Component<SuccessTableProps, SuccessTableState> ...@@ -201,7 +201,8 @@ class SuccessTable extends React.Component<SuccessTableProps, SuccessTableState>
</TabPane> </TabPane>
<TabPane tab="Log" key="2"> <TabPane tab="Log" key="2">
{ {
trainingPlatform === 'pai' || trainingPlatform === 'kubeflow' trainingPlatform === 'frameworkcontroller' || trainingPlatform === 'kubeflow' ||
trainingPlatform === 'pai'
? ?
<PaiTrialLog <PaiTrialLog
logStr={logPathRow} logStr={logPathRow}
......
...@@ -241,10 +241,10 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -241,10 +241,10 @@ class TableList extends React.Component<TableListProps, TableListState> {
const wantResult: Array<string> = []; const wantResult: Array<string> = [];
Object.keys(checkedValues).map(m => { Object.keys(checkedValues).map(m => {
switch (checkedValues[m]) { switch (checkedValues[m]) {
case 'Trial No': case 'Trial No.':
case 'id': case 'Id':
case 'duration': case 'Duration':
case 'status': case 'Status':
case 'Operation': case 'Operation':
case 'Default': case 'Default':
case 'Intermediate Result': case 'Intermediate Result':
...@@ -327,7 +327,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -327,7 +327,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
Object.keys(columnSelected).map(key => { Object.keys(columnSelected).map(key => {
const item = columnSelected[key]; const item = columnSelected[key];
switch (item) { switch (item) {
case 'Trial No': case 'Trial No.':
showColumn.push({ showColumn.push({
title: 'Trial No.', title: 'Trial No.',
dataIndex: 'sequenceId', dataIndex: 'sequenceId',
...@@ -339,7 +339,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -339,7 +339,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
(a.sequenceId as number) - (b.sequenceId as number) (a.sequenceId as number) - (b.sequenceId as number)
}); });
break; break;
case 'id': case 'Id':
showColumn.push({ showColumn.push({
title: 'Id', title: 'Id',
dataIndex: 'id', dataIndex: 'id',
...@@ -355,7 +355,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -355,7 +355,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
} }
}); });
break; break;
case 'duration': case 'Duration':
showColumn.push({ showColumn.push({
title: 'Duration', title: 'Duration',
dataIndex: 'duration', dataIndex: 'duration',
...@@ -376,7 +376,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -376,7 +376,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
}, },
}); });
break; break;
case 'status': case 'Status':
showColumn.push({ showColumn.push({
title: 'Status', title: 'Status',
dataIndex: 'status', dataIndex: 'status',
...@@ -559,7 +559,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -559,7 +559,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
</TabPane> </TabPane>
<TabPane tab="Log" key="2"> <TabPane tab="Log" key="2">
{ {
platform === 'pai' || platform === 'kubeflow' platform === 'pai' || platform === 'kubeflow' || platform === 'frameworkcontroller'
? ?
<PaiTrialLog <PaiTrialLog
logStr={logPathRow} logStr={logPathRow}
......
...@@ -21,19 +21,19 @@ const MONACO = { ...@@ -21,19 +21,19 @@ const MONACO = {
}; };
const COLUMN_INDEX = [ const COLUMN_INDEX = [
{ {
name: 'Trial No', name: 'Trial No.',
index: 1 index: 1
}, },
{ {
name: 'id', name: 'Id',
index: 2 index: 2
}, },
{ {
name: 'duration', name: 'Duration',
index: 3 index: 3
}, },
{ {
name: 'status', name: 'Status',
index: 4 index: 4
}, },
{ {
...@@ -49,7 +49,7 @@ const COLUMN_INDEX = [ ...@@ -49,7 +49,7 @@ const COLUMN_INDEX = [
index: 10001 index: 10001
} }
]; ];
const COLUMN = ['Trial No', 'id', 'duration', 'status', 'Default', 'Operation', 'Intermediate Result']; const COLUMN = ['Trial No.', 'Id', 'Duration', 'Status', 'Default', 'Operation', 'Intermediate Result'];
export { export {
MANAGER_IP, DOWNLOAD_IP, trialJobStatus, MANAGER_IP, DOWNLOAD_IP, trialJobStatus,
CONTROLTYPE, MONACO, COLUMN, COLUMN_INDEX CONTROLTYPE, MONACO, COLUMN, COLUMN_INDEX
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment