Skip to content

Commit ca48a93

Browse files
authored
Merge pull request #28 from aidy1991/modify-content
Modify content 01/003/02
2 parents bbd0694 + 65eee43 commit ca48a93

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

003cnn/002/002.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
from chainer import training
77
from chainer.training import extensions
88
import numpy as np
9-
import argparse
109

11-
train, test = chainer.datasets.get_cifar100()
10+
train, test = chainer.datasets.get_cifar10()
1211

1312
class MLP(chainer.Chain):
1413

@@ -25,11 +24,6 @@ def __call__(self, x):
2524
h2 = F.relu(self.l2(h1))
2625
return self.l3(h2)
2726

28-
parser = argparse.ArgumentParser(description='Chainer example: MNIST')
29-
parser.add_argument('--gpu', '-g', type=int, default=-1,
30-
help='GPU ID (negative value indicates CPU)')
31-
args = parser.parse_args()
32-
3327

3428
batchsize = 100
3529
train_iter = chainer.iterators.SerialIterator(train, batchsize)
@@ -38,8 +32,9 @@ def __call__(self, x):
3832

3933
model = L.Classifier(MLP(784, 10))
4034

41-
if args.gpu >= 0:
42-
chainer.cuda.get_device(args.gpu).use() # Make a specified GPU current
35+
gpu = -1
36+
if gpu >= 0:
37+
chainer.cuda.get_device(gpu).use() # Make a specified GPU current
4338
model.to_gpu() # Copy the model to the GPU
4439

4540
opt = chainer.optimizers.Adam()
@@ -49,11 +44,11 @@ def __call__(self, x):
4944
epoch = 10
5045

5146
# Set up a trainer
52-
updater = training.StandardUpdater(train_iter, opt, device=args.gpu)
53-
trainer = training.Trainer(updater, (epoch, 'epoch'), out='result')
47+
updater = training.StandardUpdater(train_iter, opt, device=gpu)
48+
trainer = training.Trainer(updater, (epoch, 'epoch'), out='/tmp/result')
5449

5550
# Evaluate the model with the test dataset for each epoch
56-
trainer.extend(extensions.Evaluator(test_iter, model, device=args.gpu))
51+
trainer.extend(extensions.Evaluator(test_iter, model, device=gpu))
5752

5853
# Dump a computational graph from 'loss' variable at the first iteration
5954
# The "main" refers to the target link of the "main" optimizer.

003cnn/002/metadata.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
uuid: 453D8CBB-9ABC-4F3D-9798-EAFBA1DD5EF3
2+
timeout: 15m

0 commit comments

Comments
 (0)