(self, z, y, is_training)
return net
Build the generator network for the given inputs.

    Args:
      z: `Tensor` of shape [batch_size, z_dim] with latent code.
      y: `Tensor` of shape [batch_size, num_classes] with one hot encoded
        labels.
      is_training: boolean, are we in train or eval model.

    Returns:
      A tensor of size [batch_size] + self._image_shape with values in [0, 1].
Build the generator network for the given inputs.
Build the generator network for the given inputs .
def apply(self, z, y, is_training):
    """Build the generator network for the given inputs.

    Args:
      z: `Tensor` of shape [batch_size, z_dim] with latent code.
      y: `Tensor` of shape [batch_size, num_classes] with one hot encoded
        labels.
      is_training: boolean, are we in train or eval model.

    Returns:
      A tensor of size [batch_size] + self._image_shape with values in [0, 1].
    """
    # Each block upscales by a factor of 2.
    seed_size = 4
    image_size = self._image_shape[0]

    # Map noise to the actual seed.
    net = ops.linear(
        z,
        self._ch * self._channels[0] * seed_size * seed_size,
        scope="fc_noise")
    # Reshape the seed to be a rank-4 Tensor.
    net = tf.reshape(
        net,
        [-1, seed_size, seed_size, self._ch * self._channels[0]],
        name="fc_reshaped")

    up_layers = np.log2(float(image_size) / seed_size)
    if not up_layers.is_integer():
      raise ValueError("log2({}/{}) must be an integer.".format(
          image_size, seed_size))
    if up_layers < 0 or up_layers > 5:
      raise ValueError("Invalid image_size {}.".format(image_size))
    up_layers = int(up_layers)

    for block_idx in range(5):
      block = self._resnet_block(
          name="B{}".format(block_idx + 1),
          in_channels=self._ch * self._channels[block_idx],
          out_channels=self._ch * self._channels[block_idx + 1],
          scale="up" if block_idx < up_layers else "none")
      net = block(net, z=z, y=y, is_training=is_training)

    net = self.batch_norm(
        net, z=z, y=y, is_training=is_training, name="final_norm")
    net = tf.nn.relu(net)
    net = ops.conv2d(net, output_dim=self._image_shape[2],
                     k_h=3, k_w=3, d_h=1, d_w=1, name="final_conv")
    net = tf.nn.sigmoid(net)
    return net
def apply ( self , z , y , is_training ) : # Each block upscales by a factor of 2. seed_size = 4 image_size = self . _image_shape [ 0 ] # Map noise to the actual seed. net = ops . linear ( z , self . _ch * self . _channels [ 0 ] * seed_size * seed_size , scope = "fc_noise" ) # Reshape the seed to be a rank-4 Tensor. net = tf . reshape ( net , [ - 1 , seed_size , seed_size , self . _ch * self . _channels [ 0 ] ] , name = "fc_reshaped" ) up_layers = np . log2 ( float ( image_size ) / seed_size ) if not up_layers . is_integer ( ) : raise ValueError ( "log2({}/{}) must be an integer." . format ( image_size , seed_size ) ) if up_layers < 0 or up_layers > 5 : raise ValueError ( "Invalid image_size {}." . format ( image_size ) ) up_layers = int ( up_layers ) for block_idx in range ( 5 ) : block = self . _resnet_block ( name = "B{}" . format ( block_idx + 1 ) , in_channels = self . _ch * self . _channels [ block_idx ] , out_channels = self . _ch * self . _channels [ block_idx + 1 ] , scale = "up" if block_idx < up_layers else "none" ) net = block ( net , z = z , y = y , is_training = is_training ) net = self . batch_norm ( net , z = z , y = y , is_training = is_training , name = "final_norm" ) net = tf . nn . relu ( net ) net = ops . conv2d ( net , output_dim = self . _image_shape [ 2 ] , k_h = 3 , k_w = 3 , d_h = 1 , d_w = 1 , name = "final_conv" ) net = tf . nn . sigmoid ( net ) return net