(x, z_dim=64)
return tdist
Make the GILBO regressor, which is based off of the GAN discriminator.
Make the GILBO regressor, which is based off of the GAN discriminator.
Make the GILBO regressor which is based off of the GAN discriminator .
def _build_regressor(x, z_dim=64):
  """Make the GILBO regressor, which is based off of the GAN discriminator."""
  net = tf.cast(x, tf.float32)
  net = layers.conv2d(net, 64, 4, 2, activation=tf.nn.leaky_relu)
  net = layers.conv2d(net, 128, 4, 2, activation=tf.nn.leaky_relu)
  net = layers.flatten(net)
  net = layers.dense(net, 1024, activation=tf.nn.leaky_relu)
  net = layers.dense(net, 2 * z_dim)
  # a and b correspond to the alpha beta parameters of the Beta distribution.
  a, b = net[..., :z_dim], net[..., z_dim:2 * z_dim]
  a = 1 + tf.nn.softplus(a - 5)
  b = 1 + tf.nn.softplus(b - 5)
  dist = ds.Independent(ds.Beta(a, b), 1)
  bijector = ds.bijectors.Affine(-1.0, 2.0)
  tdist = ds.TransformedDistribution(distribution=dist, bijector=bijector)
  return tdist
def _build_regressor ( x , z_dim = 64 ) : net = tf . cast ( x , tf . float32 ) net = layers . conv2d ( net , 64 , 4 , 2 , activation = tf . nn . leaky_relu ) net = layers . conv2d ( net , 128 , 4 , 2 , activation = tf . nn . leaky_relu ) net = layers . flatten ( net ) net = layers . dense ( net , 1024 , activation = tf . nn . leaky_relu ) net = layers . dense ( net , 2 * z_dim ) # a and b correspond to the alpha beta parameters of the Beta distribution. a , b = net [ ... , : z_dim ] , net [ ... , z_dim : 2 * z_dim ] a = 1 + tf . nn . softplus ( a - 5 ) b = 1 + tf . nn . softplus ( b - 5 ) dist = ds . Independent ( ds . Beta ( a , b ) , 1 ) bijector = ds . bijectors . Affine ( - 1.0 , 2.0 ) tdist = ds . TransformedDistribution ( distribution = dist , bijector = bijector ) return tdist