Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

from hypergan.samplers.base_sampler import BaseSampler 

 

import tensorflow as tf 

import numpy as np 

 

class BeganSampler(BaseSampler): 

def __init__(self, gan, samples_per_row): 

BaseSampler.__init__(self, gan, samples_per_row) 

self.x_v = None 

self.z_v = None 

self.created = False 

 

 

def _sample(self): 

gan = self.gan 

config = gan.config 

sess = gan.session 

x_t = gan.inputs.x 

z_t = gan.encoder.sample 

if(not self.created): 

self.x_v, self.z_v = sess.run([x_t, z_t]) 

self.created=True 

g_t = gan.generator.sample 

rx_t = gan.discriminator.reconstruction 

rx_v, g_v = sess.run([rx_t, g_t], {x_t: self.x_v, z_t: self.z_v}) 

stacks = [] 

bs = gan.batch_size() // 2 

width = self.samples_per_row 

stacks.append(self.x_v) 

stacks.append(rx_v) 

stacks.append(g_v) 

 

#[print(np.shape(s)) for s in stacks] 

images = np.vstack(stacks) 

return { 'generator':images} 

 

 

def sample(self, path, save_samples=False): 

 

self.plot(images, path, save_samples) 

return [{'image': path, 'label': 'tiled x sample'}]