"official/legacy/bert/common_flags.py" did not exist on "533d1e6b26f7fe3e4e355ec1a1aeb3277a059c8a"
Unverified Commit e9040c9b authored by chicm-ms's avatar chicm-ms Committed by GitHub
Browse files

Merge pull request #23 from microsoft/master

pull code
parents 256f27af ed63175c
...@@ -23,6 +23,7 @@ import random ...@@ -23,6 +23,7 @@ import random
from .env_vars import trial_env_vars from .env_vars import trial_env_vars
from . import trial from . import trial
from .nas_utils import classic_mode, enas_mode, oneshot_mode
__all__ = [ __all__ = [
...@@ -124,7 +125,9 @@ else: ...@@ -124,7 +125,9 @@ else:
funcs_args, funcs_args,
fixed_inputs, fixed_inputs,
optional_inputs, optional_inputs,
optional_input_size): optional_input_size,
mode='classic_mode',
tf=None):
'''execute the chosen function and inputs. '''execute the chosen function and inputs.
Below is an example of chosen function and inputs: Below is an example of chosen function and inputs:
{ {
...@@ -144,14 +147,38 @@ else: ...@@ -144,14 +147,38 @@ else:
fixed_inputs: fixed_inputs:
optional_inputs: dict of optional inputs optional_inputs: dict of optional inputs
optional_input_size: number of candidate inputs to be chosen optional_input_size: number of candidate inputs to be chosen
tf: tensorflow module
''' '''
mutable_block = _get_param(mutable_id) if mode == 'classic_mode':
chosen_layer = mutable_block[mutable_layer_id]["chosen_layer"] return classic_mode(mutable_id,
chosen_inputs = mutable_block[mutable_layer_id]["chosen_inputs"] mutable_layer_id,
real_chosen_inputs = [optional_inputs[input_name] for input_name in chosen_inputs] funcs,
layer_out = funcs[chosen_layer]([fixed_inputs, real_chosen_inputs], **funcs_args[chosen_layer]) funcs_args,
fixed_inputs,
return layer_out optional_inputs,
optional_input_size)
elif mode == 'enas_mode':
assert tf is not None, 'Internal Error: Tensorflow should not be None in enas_mode'
return enas_mode(mutable_id,
mutable_layer_id,
funcs,
funcs_args,
fixed_inputs,
optional_inputs,
optional_input_size,
tf)
elif mode == 'oneshot_mode':
assert tf is not None, 'Internal Error: Tensorflow should not be None in oneshot_mode'
return oneshot_mode(mutable_id,
mutable_layer_id,
funcs,
funcs_args,
fixed_inputs,
optional_inputs,
optional_input_size,
tf)
else:
raise RuntimeError('Unrecognized mode: %s' % mode)
def _get_param(key): def _get_param(key):
if trial._params is None: if trial._params is None:
......
...@@ -38,7 +38,13 @@ class SmartParamTestCase(TestCase): ...@@ -38,7 +38,13 @@ class SmartParamTestCase(TestCase):
'test_smartparam/choice3/choice': '[1, 2]', 'test_smartparam/choice3/choice': '[1, 2]',
'test_smartparam/choice4/choice': '{"a", 2}', 'test_smartparam/choice4/choice': '{"a", 2}',
'test_smartparam/func/function_choice': 'bar', 'test_smartparam/func/function_choice': 'bar',
'test_smartparam/lambda_func/function_choice': "lambda: 2*3" 'test_smartparam/lambda_func/function_choice': "lambda: 2*3",
'mutable_block_66':{
'mutable_layer_0':{
'chosen_layer': 'conv2D(size=5)',
'chosen_inputs': ['y']
}
}
} }
nni.trial._params = { 'parameter_id': 'test_trial', 'parameters': params } nni.trial._params = { 'parameter_id': 'test_trial', 'parameters': params }
...@@ -61,6 +67,13 @@ class SmartParamTestCase(TestCase): ...@@ -61,6 +67,13 @@ class SmartParamTestCase(TestCase):
val = nni.function_choice({"lambda: 2*3": lambda: 2*3, "lambda: 3*4": lambda: 3*4}, name = 'lambda_func', key='test_smartparam/lambda_func/function_choice') val = nni.function_choice({"lambda: 2*3": lambda: 2*3, "lambda: 3*4": lambda: 3*4}, name = 'lambda_func', key='test_smartparam/lambda_func/function_choice')
self.assertEqual(val, 6) self.assertEqual(val, 6)
def test_mutable_layer(self):
layer_out = nni.mutable_layer('mutable_block_66',
'mutable_layer_0', {'conv2D(size=3)': conv2D, 'conv2D(size=5)': conv2D}, {'conv2D(size=3)':
{'size':3}, 'conv2D(size=5)': {'size':5}}, [100], {'x':1,'y':2}, 1, 'classic_mode')
self.assertEqual(layer_out, [100, 2, 5])
def foo(): def foo():
return 'foo' return 'foo'
...@@ -68,6 +81,8 @@ def foo(): ...@@ -68,6 +81,8 @@ def foo():
def bar(): def bar():
return 'bar' return 'bar'
def conv2D(inputs, size=3):
return inputs[0] + inputs[1] + [size]
if __name__ == '__main__': if __name__ == '__main__':
main() main()
...@@ -127,7 +127,7 @@ class Compare extends React.Component<CompareProps, {}> { ...@@ -127,7 +127,7 @@ class Compare extends React.Component<CompareProps, {}> {
<td /> <td />
{Object.keys(idList).map(key => { {Object.keys(idList).map(key => {
return ( return (
<td className="value" key={key}>{idList[key]}</td> <td className="value idList" key={key}>{idList[key]}</td>
); );
})} })}
</tr> </tr>
...@@ -193,6 +193,7 @@ class Compare extends React.Component<CompareProps, {}> { ...@@ -193,6 +193,7 @@ class Compare extends React.Component<CompareProps, {}> {
destroyOnClose={true} destroyOnClose={true}
maskClosable={false} maskClosable={false}
width="90%" width="90%"
// centered={true}
> >
<Row>{this.intermediate()}</Row> <Row>{this.intermediate()}</Row>
<Row>{this.initColumn()}</Row> <Row>{this.initColumn()}</Row>
......
...@@ -353,8 +353,10 @@ class Overview extends React.Component<OverviewProps, OverviewState> { ...@@ -353,8 +353,10 @@ class Overview extends React.Component<OverviewProps, OverviewState> {
const indexarr: Array<number> = []; const indexarr: Array<number> = [];
Object.keys(sourcePoint).map(item => { Object.keys(sourcePoint).map(item => {
const items = sourcePoint[item]; const items = sourcePoint[item];
accarr.push(items.acc.default); if (items.acc !== undefined) {
indexarr.push(items.sequenceId); accarr.push(items.acc.default);
indexarr.push(items.sequenceId);
}
}); });
const accOption = { const accOption = {
// support max show 0.0000000 // support max show 0.0000000
......
...@@ -4,7 +4,7 @@ import axios from 'axios'; ...@@ -4,7 +4,7 @@ import axios from 'axios';
import { MANAGER_IP } from '../static/const'; import { MANAGER_IP } from '../static/const';
import MediaQuery from 'react-responsive'; import MediaQuery from 'react-responsive';
import { DOWNLOAD_IP } from '../static/const'; import { DOWNLOAD_IP } from '../static/const';
import { Row, Col, Menu, Dropdown, Icon, Select } from 'antd'; import { Row, Col, Menu, Dropdown, Icon, Select, Button } from 'antd';
const { SubMenu } = Menu; const { SubMenu } = Menu;
const { Option } = Select; const { Option } = Select;
import '../static/style/slideBar.scss'; import '../static/style/slideBar.scss';
...@@ -14,6 +14,7 @@ interface SliderState { ...@@ -14,6 +14,7 @@ interface SliderState {
version: string; version: string;
menuVisible: boolean; menuVisible: boolean;
navBarVisible: boolean; navBarVisible: boolean;
isdisabledFresh: boolean;
} }
interface SliderProps { interface SliderProps {
...@@ -29,7 +30,6 @@ class SlideBar extends React.Component<SliderProps, SliderState> { ...@@ -29,7 +30,6 @@ class SlideBar extends React.Component<SliderProps, SliderState> {
public _isMounted = false; public _isMounted = false;
public divMenu: HTMLDivElement | null; public divMenu: HTMLDivElement | null;
public countOfMenu: number = 0;
public selectHTML: Select | null; public selectHTML: Select | null;
constructor(props: SliderProps) { constructor(props: SliderProps) {
...@@ -38,6 +38,7 @@ class SlideBar extends React.Component<SliderProps, SliderState> { ...@@ -38,6 +38,7 @@ class SlideBar extends React.Component<SliderProps, SliderState> {
version: '', version: '',
menuVisible: false, menuVisible: false,
navBarVisible: false, navBarVisible: false,
isdisabledFresh: false
}; };
} }
...@@ -208,7 +209,6 @@ class SlideBar extends React.Component<SliderProps, SliderState> { ...@@ -208,7 +209,6 @@ class SlideBar extends React.Component<SliderProps, SliderState> {
} }
menu = () => { menu = () => {
this.countOfMenu = 0;
return ( return (
<Menu onClick={this.handleMenuClick}> <Menu onClick={this.handleMenuClick}>
<Menu.Item key="1">Experiment Parameters</Menu.Item> <Menu.Item key="1">Experiment Parameters</Menu.Item>
...@@ -223,12 +223,9 @@ class SlideBar extends React.Component<SliderProps, SliderState> { ...@@ -223,12 +223,9 @@ class SlideBar extends React.Component<SliderProps, SliderState> {
const { version } = this.state; const { version } = this.state;
const feedBackLink = `https://github.com/Microsoft/nni/issues/new?labels=${version}`; const feedBackLink = `https://github.com/Microsoft/nni/issues/new?labels=${version}`;
return ( return (
<Menu onClick={this.handleMenuClick} mode="inline"> <Menu onClick={this.handleMenuClick} className="menuModal">
<Menu.Item key="overview"><Link to={'/oview'}>Overview</Link></Menu.Item> <Menu.Item key="overview"><Link to={'/oview'}>Overview</Link></Menu.Item>
<Menu.Item key="detail"><Link to={'/detail'}>Trials detail</Link></Menu.Item> <Menu.Item key="detail"><Link to={'/detail'}>Trials detail</Link></Menu.Item>
<Menu.Item key="fresh">
<span className="fresh" onClick={this.fresh}><span>Fresh</span></span>
</Menu.Item>
<Menu.Item key="feedback"> <Menu.Item key="feedback">
<a href={feedBackLink} target="_blank">Feedback</a> <a href={feedBackLink} target="_blank">Feedback</a>
</Menu.Item> </Menu.Item>
...@@ -250,38 +247,42 @@ class SlideBar extends React.Component<SliderProps, SliderState> { ...@@ -250,38 +247,42 @@ class SlideBar extends React.Component<SliderProps, SliderState> {
); );
} }
// nav bar <1299
showMenu = () => {
if (this.divMenu !== null) {
this.countOfMenu = this.countOfMenu + 1;
if (this.countOfMenu % 2 === 0) {
this.divMenu.setAttribute('class', 'hide');
} else {
this.divMenu.setAttribute('class', 'show');
}
}
}
select = () => { select = () => {
const { isdisabledFresh } = this.state;
return ( return (
<Select <div className="interval">
onSelect={this.getInterval} <Button
defaultValue="Refresh every 10s" className="fresh"
className="interval" onClick={this.fresh}
> type="ghost"
<Option value="close">Disable Auto Refresh</Option> disabled={isdisabledFresh}
<Option value="10">Refresh every 10s</Option> >
<Option value="20">Refresh every 20s</Option> <Icon type="sync" /><span>Refresh</span>
<Option value="30">Refresh every 30s</Option> </Button>
<Option value="60">Refresh every 1min</Option> <Select
</Select> onSelect={this.getInterval}
defaultValue="Refresh every 10s"
>
<Option value="close">Disable Auto Refresh</Option>
<Option value="10">Refresh every 10s</Option>
<Option value="20">Refresh every 20s</Option>
<Option value="30">Refresh every 30s</Option>
<Option value="60">Refresh every 1min</Option>
</Select>
</div>
); );
} }
fresh = (event: React.SyntheticEvent<EventTarget>) => { fresh = (event: React.SyntheticEvent<EventTarget>) => {
event.preventDefault(); event.preventDefault();
const whichPage = window.location.pathname; event.stopPropagation();
this.props.changeFresh(whichPage); if (this._isMounted) {
this.setState({ isdisabledFresh: true }, () => {
const whichPage = window.location.pathname;
this.props.changeFresh(whichPage);
setTimeout(() => { this.setState(() => ({ isdisabledFresh: false })); }, 1000);
});
}
} }
componentDidMount() { componentDidMount() {
...@@ -298,73 +299,75 @@ class SlideBar extends React.Component<SliderProps, SliderState> { ...@@ -298,73 +299,75 @@ class SlideBar extends React.Component<SliderProps, SliderState> {
const feed = `https://github.com/Microsoft/nni/issues/new?labels=${version}`; const feed = `https://github.com/Microsoft/nni/issues/new?labels=${version}`;
return ( return (
<Row> <Row>
<MediaQuery query="(min-width: 1299px)"> <Col span={18}>
<Row className="nav"> <MediaQuery query="(min-width: 1299px)">
<ul className="link"> <Row className="nav">
<li className="logo"> <ul className="link">
<li className="logo">
<Link to={'/oview'}>
<img
src={require('../static/img/logo2.png')}
style={{ width: 88 }}
alt="NNI logo"
/>
</Link>
</li>
<li className="tab firstTab">
<Link to={'/oview'} activeClassName="high">
Overview
</Link>
</li>
<li className="tab">
<Link to={'/detail'} activeClassName="high">
Trials detail
</Link>
</li>
<li className="feedback">
<Dropdown
className="dropdown"
overlay={this.menu()}
onVisibleChange={this.handleVisibleChange}
visible={menuVisible}
trigger={['click']}
>
<a className="ant-dropdown-link" href="#">
Download <Icon type="down" />
</a>
</Dropdown>
<a href={feed} target="_blank">
<img
src={require('../static/img/icon/issue.png')}
alt="NNI github issue"
/>
Feedback
</a>
<span className="version">Version: {version}</span>
</li>
</ul>
</Row>
</MediaQuery>
</Col>
<Col span={18}>
<MediaQuery query="(max-width: 1299px)">
<Row className="little">
<Col span={1} className="menu">
<Dropdown overlay={this.navigationBar()} trigger={['click']}>
<Icon type="unordered-list" className="more" />
</Dropdown>
</Col>
<Col span={14} className="logo">
<Link to={'/oview'}> <Link to={'/oview'}>
<img <img
src={require('../static/img/logo2.png')} src={require('../static/img/logo2.png')}
style={{ width: 88 }} style={{ width: 80 }}
alt="NNI logo" alt="NNI logo"
/> />
</Link> </Link>
</li> </Col>
<li className="tab firstTab"> </Row>
<Link to={'/oview'} activeClassName="high"> </MediaQuery>
Overview </Col>
</Link> <Col span={3}> {this.select()} </Col>
</li>
<li className="tab">
<Link to={'/detail'} activeClassName="high">
Trials detail
</Link>
</li>
<li className="feedback">
<span className="fresh" onClick={this.fresh}>
<Icon type="sync"/><span>Fresh</span>
</span>
<Dropdown
className="dropdown"
overlay={this.menu()}
onVisibleChange={this.handleVisibleChange}
visible={menuVisible}
trigger={['click']}
>
<a className="ant-dropdown-link" href="#">
Download <Icon type="down" />
</a>
</Dropdown>
<a href={feed} target="_blank">
<img
src={require('../static/img/icon/issue.png')}
alt="NNI github issue"
/>
Feedback
</a>
<span className="version">Version: {version}</span>
</li>
</ul>
</Row>
</MediaQuery>
<MediaQuery query="(max-width: 1299px)">
<Row className="little">
<Col span={6} className="menu">
<Icon type="unordered-list" className="more" onClick={this.showMenu} />
<div ref={div => this.divMenu = div} className="hide">{this.navigationBar()}</div>
</Col>
<Col span={10} className="logo">
<Link to={'/oview'}>
<img
src={require('../static/img/logo2.png')}
style={{ width: 88 }}
alt="NNI logo"
/>
</Link>
</Col>
</Row>
</MediaQuery>
{this.select()}
</Row> </Row>
); );
} }
......
...@@ -394,15 +394,13 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState> ...@@ -394,15 +394,13 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
</Col> </Col>
<Col span={14} className="right"> <Col span={14} className="right">
<Button <Button
type="primary" className="common"
className="tableButton editStyle"
onClick={this.tableList ? this.tableList.addColumn : this.test} onClick={this.tableList ? this.tableList.addColumn : this.test}
> >
Add column Add column
</Button> </Button>
<Button <Button
type="primary" className="mediateBtn common"
className="tableButton editStyle mediateBtn"
// use child-component tableList's function, the function is in child-component. // use child-component tableList's function, the function is in child-component.
onClick={this.tableList ? this.tableList.compareBtn : this.test} onClick={this.tableList ? this.tableList.compareBtn : this.test}
> >
......
...@@ -163,9 +163,9 @@ class Duration extends React.Component<DurationProps, DurationState> { ...@@ -163,9 +163,9 @@ class Duration extends React.Component<DurationProps, DurationState> {
} }
shouldComponentUpdate(nextProps: DurationProps, nextState: DurationState) { shouldComponentUpdate(nextProps: DurationProps, nextState: DurationState) {
const { whichGraph, source } = nextProps; const { whichGraph, source } = nextProps;
if (whichGraph === '3') { if (whichGraph === '3') {
const beforeSource = this.props.source; const beforeSource = this.props.source;
if (whichGraph !== this.props.whichGraph) { if (whichGraph !== this.props.whichGraph) {
return true; return true;
...@@ -174,13 +174,14 @@ class Duration extends React.Component<DurationProps, DurationState> { ...@@ -174,13 +174,14 @@ class Duration extends React.Component<DurationProps, DurationState> {
if (source.length !== beforeSource.length) { if (source.length !== beforeSource.length) {
return true; return true;
} }
if (source[source.length - 1].duration !== beforeSource[beforeSource.length - 1].duration) {
return true;
}
if (source[source.length - 1].status !== beforeSource[beforeSource.length - 1].status) { if (beforeSource[beforeSource.length - 1] !== undefined) {
return true; if (source[source.length - 1].duration !== beforeSource[beforeSource.length - 1].duration) {
return true;
}
if (source[source.length - 1].status !== beforeSource[beforeSource.length - 1].status) {
return true;
}
} }
} }
return false; return false;
......
.compare{ .compare{
width: 92%; width: 92%;
table-layout: fixed;
margin: 0 auto; margin: 0 auto;
color: #333; color: #333;
tr{ tr{
line-height: 30px; line-height: 30px;
border-bottom: 1px solid #ccc; }
tr:nth-of-type(even){
background-color: gainsboro;
} }
.column{ .column{
width: 124px; max-width: 124px;
padding-left: 18px; padding-left: 18px;
font-weight: 700; font-weight: 700;
} }
.value{ .value{
width: 152px; max-width: 152px;
padding-right: 18px; padding-right: 18px;
text-align: right; text-align: left;
}
.idList{
font-weight: 700;
} }
} }
...@@ -4,6 +4,13 @@ ...@@ -4,6 +4,13 @@
margin: 0 auto; margin: 0 auto;
.right{ .right{
text-align: right; text-align: right;
.common{
border-radius: 0;
}
.common:hover{
color: #0071BC;
border-radius: 0;
}
} }
.entry{ .entry{
width: 120px; width: 120px;
...@@ -31,8 +38,9 @@ ...@@ -31,8 +38,9 @@
} }
} }
/* compare button style */
Button.mediateBtn{ Button.mediateBtn{
margin: 0 32px; margin: 0 2px 0 8px;
} }
/* each row's Intermediate btn -> Modal*/ /* each row's Intermediate btn -> Modal*/
......
This diff is collapsed.
This diff is collapsed.
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
## 问题 ## 问题
* 使用了私有 API 来检测是否 Tuner 和 Assessor 成功结束。 * 使用了私有 API 来检测是否 Tuner 和 Assessor 成功结束。
* RESTful 服务的输出未测试。 * RESTful 服务的输出未测试。
* 远程计算机训练服务没有测试。 * 远程计算机训练服务没有测试。
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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