Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Erik Linder-Norén
PyTorch-GAN
Merge requests
!174
fix WGAN-GP alpha dimension error
Code
Review changes
Check out branch
Download
Email patches
Plain diff
Closed
Administrator
requested to merge
github/fork/sudrizzz/master
into
master
3 years ago
Overview
1
Commits
1
Pipelines
0
Changes
1
Created by: sudrizzz
0
0
Compare
master
master (base)
and
latest version
latest version
3815b577
1 commit,
2 years ago
1 file
+
1
-
1
Expand all files
Preferences
Preferences
File browser
List view
Tree view
Compare changes
Inline
Side-by-side
Show whitespace changes
Show one file at a time
implementations/wgan_gp/wgan_gp.py
+
1
-
1
Options
View file @ 3815b577
Show full file
@@ -119,7 +119,7 @@ Tensor = torch.cuda.FloatTensor if cuda else torch.FloatTensor
def
compute_gradient_penalty
(
D
,
real_samples
,
fake_samples
):
"""Calculates the gradient penalty loss for WGAN GP"""
# Random weight term for interpolation between real and fake samples
alpha
=
Tensor
(
np
.
random
.
random
((
real_samples
.
size
(
0
),
1
,
1
,
1
)))
alpha
=
Tensor
(
np
.
random
.
random
((
real_samples
.
size
(
0
),
1
)))
# Get random interpolation between real and fake samples
interpolates
=
(
alpha
*
real_samples
+
((
1
-
alpha
)
*
fake_samples
)).
requires_grad_
(
True
)
d_interpolates
=
D
(
interpolates
)
Menu
Explore
Projects
Groups
Snippets