Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HAP_Tutorial_2018
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Josef Schmidt
HAP_Tutorial_2018
Commits
07669ccb
Commit
07669ccb
authored
7 years ago
by
Lukas Geiger
Browse files
Options
Downloads
Patches
Plain Diff
Fix Python 3 compatibility
parent
9fca1db0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
MNIST_GAN/MNIST_GAN.py
+5
-5
5 additions, 5 deletions
MNIST_GAN/MNIST_GAN.py
with
5 additions
and
5 deletions
MNIST_GAN/MNIST_GAN.py
+
5
−
5
View file @
07669ccb
...
...
@@ -72,14 +72,14 @@ y[ntrain:, 0] = 1 # class 0 for generated images
discriminator
.
fit
(
X
,
y
,
epochs
=
1
,
batch_size
=
128
)
# - Create a dataset of 5000 real test images and 5000 fake images.
no
=
np
.
random
.
choice
(
10000
,
size
=
ntrain
/
2
,
replace
=
'
False
'
)
no
=
np
.
random
.
choice
(
10000
,
size
=
ntrain
/
/
2
,
replace
=
'
False
'
)
real_test
=
X_test
[
no
,
:,
:,
:]
# sample real images from test set
noise_gen
=
np
.
random
.
uniform
(
0
,
1
,
size
=
[
ntrain
/
2
,
latent_dim
])
noise_gen
=
np
.
random
.
uniform
(
0
,
1
,
size
=
[
ntrain
/
/
2
,
latent_dim
])
generated_images
=
generator
.
predict
(
noise_gen
)
# generate fake images with untrained generator
Xt
=
np
.
concatenate
((
real_test
,
generated_images
))
yt
=
np
.
zeros
([
ntrain
,
2
])
# class vector: one-hot encoding
yt
[:
ntrain
/
2
,
1
]
=
1
# class 1 for real images
yt
[
ntrain
/
2
:,
0
]
=
1
# class 0 for generated images
yt
[:
ntrain
/
/
2
,
1
]
=
1
# class 1 for real images
yt
[
ntrain
/
/
2
:,
0
]
=
1
# class 0 for generated images
# - Evaluate the test accuracy of your network.
pretrain_loss
,
pretrain_acc
=
discriminator
.
evaluate
(
Xt
,
yt
,
verbose
=
0
,
batch_size
=
128
)
...
...
@@ -99,7 +99,7 @@ def train_for_n(epochs=1, batch_size=32):
generated_images
=
generator
.
predict
(
noise
)
plot_images
(
generated_images
,
fname
=
log_dir
+
'
/generated_images_
'
+
str
(
epoch
))
iterations_per_epoch
=
60000
/
batch_size
# number of training steps per epoch
iterations_per_epoch
=
60000
/
/
batch_size
# number of training steps per epoch
perm
=
np
.
random
.
choice
(
60000
,
size
=
60000
,
replace
=
'
False
'
)
for
i
in
range
(
iterations_per_epoch
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment