Ejemplo n.º 1
0
    def resample_feed(self):
        """
        random z_noise
        """
        z = ops.get_random("normal", self.z_shape)
        self.feed.update({self.z_noise: z})

        if self.FLAGS.cgan:
            if self.c_shape[1] == 34:
                c = ops.get_random("getchu_boolean", self.c_shape)
            else:
                c = ops.get_random("boolean", self.c_shape)
            self.feed.update({self.c_noise: c})
Ejemplo n.º 2
0
    def make_fixed_feed(self):
        self.fixed_feed = {
            self.gen_model.keep_prob: 1.0,
            self.disc_model.keep_prob: 1.0,
            self.gen_model.training: False,
            self.disc_model.training: False
        }

        self.fixed_noise = ops.get_random("normal", self.z_shape)

        if self.FLAGS.cgan:
            if self.c_shape[1] == 34:
                self.fixed_cond = ops.get_random("getchu_boolean",
                                                 self.c_shape)
            else:
                self.fixed_cond = ops.get_random("boolean", self.c_shape)

            self.fixed_feed.update({
                self.z_noise: self.fixed_noise,
                self.c_noise: self.fixed_cond
            })
        else:
            self.fixed_feed.update({self.z_noise: self.fixed_noise})
Ejemplo n.º 3
0
    def get_noise_batch(self, raw_z, lr, grad):
        print("=> noise: min=%f, max=%f" % (raw_z.min(), raw_z.max()))
        grad_std = np.std(grad)

        noise_list = [raw_z - lr * grad]

        for i in range(3):
            noise_list.append(raw_z - (2**(i + 1)) * lr * grad)
        for i in range(4):
            noise_list.append(raw_z - (2**i) * lr * grad +
                              lr * ops.get_random("normal", raw_z.shape) *
                              grad_std * 0.1)

        noise_list = np.concatenate(noise_list, axis=0)
        noise_list = np.maximum(noise_list, -self.RANGE)
        noise_list = np.minimum(noise_list, self.RANGE)
        return noise_list
Ejemplo n.º 4
0
 def get_z_noise(self):
     # origin raw z noise: guassian with 3 sigma
     self.origin_raw_z = ops.get_random("normal", (1, 128)) * 3
Ejemplo n.º 5
0
 def get_c_noise(self):
     if self.using_cgan == False: return
     # raw c noise is gaussian
     self.origin_raw_c = ops.get_random("normal", (1, self.n_attrs))