Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

add config test for mnist torch exp #1523

Merged
merged 6 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions examples/trials/mnist-pytorch/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,16 @@ def main(args):
train(args, model, device, train_loader, optimizer, epoch)
test_acc = test(args, model, device, test_loader)

# report intermediate result
nni.report_intermediate_result(test_acc)
logger.debug('test accuracy %g', test_acc)
logger.debug('Pipe send intermediate result done.')

test_acc = test(args, model, device, test_loader)
# report final result
nni.report_final_result(test_acc)
logger.debug('Final result is %g', test_acc)
logger.debug('Send final result done.')

if epoch < args['epochs']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference between the original version and this change(111-120 line)? Seems are same? Why change here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original version, the final result will be reported twice: once as intermediate-result, once as final result. This leads to a duplicated display in the learning curve of WebUI.

# report intermediate result
nni.report_intermediate_result(test_acc)
logger.debug('test accuracy %g', test_acc)
logger.debug('Pipe send intermediate result done.')
else:
# report final result
nni.report_final_result(test_acc)
logger.debug('Final result is %g', test_acc)
logger.debug('Send final result done.')


def get_params():
Expand Down
23 changes: 23 additions & 0 deletions test/config_test/examples/mnist-pytorch.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
authorName: nni
experimentName: default_test
maxExecDuration: 15m
maxTrialNum: 4
trialConcurrency: 2
searchSpacePath: ./mnist_pytorch_search_space.json

tuner:
builtinTunerName: Random
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ../../../examples/trials/mnist-pytorch
command: python3 mnist.py --epochs 2
gpuNum: 0

useAnnotation: false
multiPhase: false
multiThread: false

trainingServicePlatform: local
6 changes: 6 additions & 0 deletions test/config_test/examples/mnist_pytorch_search_space.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"batch_size": {"_type":"choice", "_value": [16, 32, 64, 128]},
"hidden_size":{"_type":"choice","_value":[128, 256, 512, 1024]},
"lr":{"_type":"choice","_value":[0.0001, 0.001, 0.01, 0.1]},
"momentum":{"_type":"uniform","_value":[0, 1]}
}