Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
apex
Commits
39c9be85
Commit
39c9be85
authored
Aug 16, 2018
by
Michael Carilli
Browse files
Syncing imagenet examples to use distributed validation
parent
7d0aef9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
examples/imagenet/main_fp16_optimizer.py
examples/imagenet/main_fp16_optimizer.py
+9
-6
No files found.
examples/imagenet/main_fp16_optimizer.py
View file @
39c9be85
...
...
@@ -175,23 +175,26 @@ def main():
# transforms.ToTensor(), Too slow
# normalize,
]))
val_dataset
=
datasets
.
ImageFolder
(
valdir
,
transforms
.
Compose
([
transforms
.
Resize
(
val_size
),
transforms
.
CenterCrop
(
crop_size
),
]))
train_sampler
=
None
val_sampler
=
None
if
args
.
distributed
:
train_sampler
=
torch
.
utils
.
data
.
distributed
.
DistributedSampler
(
train_dataset
)
else
:
train_sampler
=
None
val_sampler
=
torch
.
utils
.
data
.
distributed
.
DistributedSampler
(
val_dataset
)
train_loader
=
torch
.
utils
.
data
.
DataLoader
(
train_dataset
,
batch_size
=
args
.
batch_size
,
shuffle
=
(
train_sampler
is
None
),
num_workers
=
args
.
workers
,
pin_memory
=
True
,
sampler
=
train_sampler
,
collate_fn
=
fast_collate
)
val_loader
=
torch
.
utils
.
data
.
DataLoader
(
datasets
.
ImageFolder
(
valdir
,
transforms
.
Compose
([
transforms
.
Resize
(
val_size
),
transforms
.
CenterCrop
(
crop_size
),
])),
val_dataset
,
batch_size
=
args
.
batch_size
,
shuffle
=
False
,
num_workers
=
args
.
workers
,
pin_memory
=
True
,
sampler
=
val_sampler
,
collate_fn
=
fast_collate
)
if
args
.
evaluate
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment