-
Notifications
You must be signed in to change notification settings - Fork 0
/
herold.py
47 lines (32 loc) · 978 Bytes
/
herold.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import matplotlib.pyplot as plt
from gan.degan_mnist import DEGAN_MNIST
from herold.mnist import MNIST_provider
def test_provider():
provider = MNIST_provider(1000)
i = 0
for batch in provider.get_numbers():
print(f"batch {i} ... {batch.shape}")
i += 1
def mnist_training():
epochs = 1
provider = MNIST_provider(128)
gan = DEGAN_MNIST()
gan.set_training_data(provider.get_numbers)
for epoch in range(epochs):
i = 0
# start training
for image_batch in provider.get_numbers():
print(f"batch {i}")
gan.train_step(image_batch)
i += 1
break
gan._generate_and_save_images(gan.generator, epoch, gan.seed)
# end training
gan.export()
# gan.generate_gif()
if __name__ == "__main__":
mnist_training()