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
b572d5e6
"vscode:/vscode.git/clone" did not exist on "19f53cf249d69c81be3005d582d37530f0a3aef7"
Unverified
Commit
b572d5e6
authored
Jul 07, 2020
by
vfdev
Committed by
GitHub
Jul 07, 2020
Browse files
Fixed torch randint incoherent sampling (compatible to random.randint) (#2401)
parent
86b6c3e2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
torchvision/transforms/transforms.py
torchvision/transforms/transforms.py
+4
-4
No files found.
torchvision/transforms/transforms.py
View file @
b572d5e6
...
...
@@ -510,8 +510,8 @@ class RandomCrop(torch.nn.Module):
if
w
==
tw
and
h
==
th
:
return
0
,
0
,
h
,
w
i
=
torch
.
randint
(
0
,
h
-
th
,
size
=
(
1
,
)).
item
()
j
=
torch
.
randint
(
0
,
w
-
tw
,
size
=
(
1
,
)).
item
()
i
=
torch
.
randint
(
0
,
h
-
th
+
1
,
size
=
(
1
,
)).
item
()
j
=
torch
.
randint
(
0
,
w
-
tw
+
1
,
size
=
(
1
,
)).
item
()
return
i
,
j
,
th
,
tw
def
__init__
(
self
,
size
,
padding
=
None
,
pad_if_needed
=
False
,
fill
=
0
,
padding_mode
=
"constant"
):
...
...
@@ -1433,8 +1433,8 @@ class RandomErasing(torch.nn.Module):
else
:
v
=
torch
.
tensor
(
value
)[:,
None
,
None
]
i
=
torch
.
randint
(
0
,
img_h
-
h
,
size
=
(
1
,
)).
item
()
j
=
torch
.
randint
(
0
,
img_w
-
w
,
size
=
(
1
,
)).
item
()
i
=
torch
.
randint
(
0
,
img_h
-
h
+
1
,
size
=
(
1
,
)).
item
()
j
=
torch
.
randint
(
0
,
img_w
-
w
+
1
,
size
=
(
1
,
)).
item
()
return
i
,
j
,
h
,
w
,
v
# Return original image
...
...
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