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
'''
from enum import Enum, unique
import sys
import math
import copy
import logging
......@@ -140,13 +141,6 @@ class Bracket():
value: latest result with sequence number seq
'''
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:
self.configs_perf[i][parameter_id] = [seq, value]
else:
......@@ -214,6 +208,14 @@ class Bracket():
self.num_configs_to_run.append(len(hyper_configs))
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):
'''
......@@ -345,12 +347,16 @@ class Hyperband(MsgDispatcherBase):
'''
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':
# 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)
elif data['type'] == 'PERIODICAL':
bracket_id, i, _ = data['parameter_id'].split('_')
bracket_id = int(bracket_id)
self.brackets[bracket_id].set_config_perf(int(i), data['parameter_id'], data['sequence'], data['value'])
self.brackets[bracket_id].set_config_perf(int(i), data['parameter_id'], data['sequence'], value)
else:
raise ValueError('Data type not supported: {}'.format(data['type']))
......
......@@ -132,10 +132,15 @@ class MetisTuner(Tuner):
self.x_types[idx] = 'range_continuous'
elif key_type == 'choice':
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'
else:
logger.info("Metis Tuner doesn't support this kind of variable.")
raise RuntimeError("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: " + str(key_type))
else:
logger.info("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
## 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
{
......@@ -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.
- `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_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).
......
......@@ -2,6 +2,7 @@
font-family: 'Segoe';
color: #212121;
font-size: 14px;
background: #f2f2f2;
}
.header{
......@@ -19,7 +20,6 @@
}
.contentBox{
width: 100%;
background: #f2f2f2;
}
.content{
width: 86%;
......
import * as React from 'react';
import { Row, Button } from 'antd';
import { Row } from 'antd';
import { DOWNLOAD_IP } from '../../static/const';
interface PaiTrialChildProps {
......@@ -17,7 +17,7 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> {
}
render() {
const { logString, id, showLogModal, isdisLogbtn } = this.props;
const { logString, id } = this.props;
return (
<div>
{
......@@ -35,16 +35,6 @@ class PaiTrialChild extends React.Component<PaiTrialChildProps, {}> {
trial stdout
</a>
</Row>
<Row>
<Button
disabled={isdisLogbtn}
type="primary"
className="tableButton"
onClick={showLogModal.bind(this, id)}
>
View
</Button>
</Row>
</Row>
}
</div>
......
import * as React from 'react';
import { Row, Button } from 'antd';
import { Row } from 'antd';
import { DOWNLOAD_IP } from '../../static/const';
import PaiTrialChild from './PaiTrialChild';
......@@ -44,16 +44,6 @@ class PaitrialLog extends React.Component<PaitrialLogProps, {}> {
</a>
<a target="_blank" href={logStr.split(',')[1]}>hdfsLog</a>
</Row>
<Row>
<Button
disabled={isdisLogbutton}
type="primary"
className="tableButton"
onClick={showLogModal.bind(this, id)}
>
View
</Button>
</Row>
</Row>
:
<PaiTrialChild
......
......@@ -201,7 +201,8 @@ class SuccessTable extends React.Component<SuccessTableProps, SuccessTableState>
</TabPane>
<TabPane tab="Log" key="2">
{
trainingPlatform === 'pai' || trainingPlatform === 'kubeflow'
trainingPlatform === 'frameworkcontroller' || trainingPlatform === 'kubeflow' ||
trainingPlatform === 'pai'
?
<PaiTrialLog
logStr={logPathRow}
......
......@@ -241,10 +241,10 @@ class TableList extends React.Component<TableListProps, TableListState> {
const wantResult: Array<string> = [];
Object.keys(checkedValues).map(m => {
switch (checkedValues[m]) {
case 'Trial No':
case 'id':
case 'duration':
case 'status':
case 'Trial No.':
case 'Id':
case 'Duration':
case 'Status':
case 'Operation':
case 'Default':
case 'Intermediate Result':
......@@ -327,7 +327,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
Object.keys(columnSelected).map(key => {
const item = columnSelected[key];
switch (item) {
case 'Trial No':
case 'Trial No.':
showColumn.push({
title: 'Trial No.',
dataIndex: 'sequenceId',
......@@ -339,7 +339,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
(a.sequenceId as number) - (b.sequenceId as number)
});
break;
case 'id':
case 'Id':
showColumn.push({
title: 'Id',
dataIndex: 'id',
......@@ -355,7 +355,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
}
});
break;
case 'duration':
case 'Duration':
showColumn.push({
title: 'Duration',
dataIndex: 'duration',
......@@ -376,7 +376,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
},
});
break;
case 'status':
case 'Status':
showColumn.push({
title: 'Status',
dataIndex: 'status',
......@@ -559,7 +559,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
</TabPane>
<TabPane tab="Log" key="2">
{
platform === 'pai' || platform === 'kubeflow'
platform === 'pai' || platform === 'kubeflow' || platform === 'frameworkcontroller'
?
<PaiTrialLog
logStr={logPathRow}
......
......@@ -21,19 +21,19 @@ const MONACO = {
};
const COLUMN_INDEX = [
{
name: 'Trial No',
name: 'Trial No.',
index: 1
},
{
name: 'id',
name: 'Id',
index: 2
},
{
name: 'duration',
name: 'Duration',
index: 3
},
{
name: 'status',
name: 'Status',
index: 4
},
{
......@@ -49,7 +49,7 @@ const COLUMN_INDEX = [
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 {
MANAGER_IP, DOWNLOAD_IP, trialJobStatus,
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