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
vision
Commits
aafaa2a1
Commit
aafaa2a1
authored
Dec 06, 2017
by
Jon Crall
Committed by
Alykhan Tejani
Dec 06, 2017
Browse files
param to cause FakeData to generate different images (#358)
* param to cause FakeData to generate different images
parent
49273094
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
torchvision/datasets/fakedata.py
torchvision/datasets/fakedata.py
+6
-2
No files found.
torchvision/datasets/fakedata.py
View file @
aafaa2a1
...
...
@@ -14,15 +14,19 @@ class FakeData(data.Dataset):
and returns a transformed version. E.g, ``transforms.RandomCrop``
target_transform (callable, optional): A function/transform that takes in the
target and transforms it.
random_offset (int): Offsets the index-based random seed used to
generate each image. Default: 0
"""
def
__init__
(
self
,
size
=
1000
,
image_size
=
(
3
,
224
,
224
),
num_classes
=
10
,
transform
=
None
,
target_transform
=
None
):
def
__init__
(
self
,
size
=
1000
,
image_size
=
(
3
,
224
,
224
),
num_classes
=
10
,
transform
=
None
,
target_transform
=
None
,
random_offset
=
0
):
self
.
size
=
size
self
.
num_classes
=
num_classes
self
.
image_size
=
image_size
self
.
transform
=
transform
self
.
target_transform
=
target_transform
self
.
random_offset
=
random_offset
def
__getitem__
(
self
,
index
):
"""
...
...
@@ -34,7 +38,7 @@ class FakeData(data.Dataset):
"""
# create random image that is consistent with the index id
rng_state
=
torch
.
get_rng_state
()
torch
.
manual_seed
(
index
)
torch
.
manual_seed
(
index
+
self
.
random_offset
)
img
=
torch
.
randn
(
*
self
.
image_size
)
target
=
torch
.
Tensor
(
1
).
random_
(
0
,
self
.
num_classes
)[
0
]
torch
.
set_rng_state
(
rng_state
)
...
...
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