def make_encoder(self, state, z_size, scope, n_layers, hid_size): """ ### PROBLEM 3 ### YOUR CODE HERE args: state: tf variable z_size: output dimension of the encoder network scope: scope name n_layers: number of layers of the encoder network hid_size: hidden dimension of encoder network TODO: 1. z_mean: the output of a neural network that takes the state as input, has output dimension z_size, n_layers layers, and hidden dimension hid_size 2. z_logstd: a trainable variable, initialized to 0 shape (z_size,) Hint: use build_mlp """ z_mean = build_mlp(state, z_size, scope, n_layers, hid_size) z_logstd = tf.Variable(tf.zeros(z_size)) return tfp.distributions.MultivariateNormalDiag( loc=z_mean, scale_diag=tf.exp(z_logstd))
def make_discriminator(self, z, output_size, scope, n_layers, hid_size): """ ### PROBLEM 3 ### YOUR CODE HERE args: z: input to to discriminator network output_size: output dimension of discriminator network scope: scope name n_layers: number of layers of discriminator network hid_size: hidden dimension of discriminator network TODO: 1. logit: the output of a neural network that takes z as input, has output size output_size, n_layers layers, and hidden dimension hid_size Hint: use build_mlp """ logit = build_mlp(z, output_size, scope, n_layers=n_layers, size=hid_size) return tfp.distributions.Bernoulli(logit)
def make_discriminator(self, z, output_size, scope, n_layers, hid_size): """ args: z: input to to discriminator network output_size: output dimension of discriminator network scope: scope name n_layers: number of layers of discriminator network hid_size: hidden dimension of discriminator network TODO: 1. logit: the output of a neural network that takes z as input, has output size output_size, n_layers layers, and hidden dimension hid_size Hint: use build_mlp """ logit = build_mlp( input_placeholder=z, output_size=output_size, scope=scope, n_layers=n_layers, size=hid_size, activation=tf.tanh, output_activation=None ) return tfp.distributions.Bernoulli(logit)
def make_encoder(self, state, z_size, scope, n_layers, hid_size): """ ### PROBLEM 3 ### YOUR CODE HERE args: state: tf variable z_size: output dimension of the encoder network scope: scope name n_layers: number of layers of the encoder network hid_size: hidden dimension of encoder network TODO: 1. z_mean: the output of a neural network that takes the state as input, has output dimension z_size, n_layers layers, and hidden dimension hid_size 2. z_logstd: a trainable variable, initialized to 0 shape (z_size,) Hint: use build_mlp """ z_mean = build_mlp(input_placeholder=state, output_size=z_size, scope=scope, n_layers=n_layers, size=hid_size) z_logstd = tf.get_variable('log_std', shape=[z_size], dtype=tf.float32, initializer=tf.constant_initializer(0), trainable=True) return tfp.distributions.MultivariateNormalDiag( loc=z_mean, scale_diag=tf.exp(z_logstd))
def make_encoder(self, state, z_size, scope, n_layers, hid_size): """ args: state: tf variable z_size: output dimension of the encoder network scope: scope name n_layers: number of layers of the encoder network hid_size: hidden dimension of encoder network TODO: 1. z_mean: the output of a neural network that takes the state as input, has output dimension z_size, n_layers layers, and hidden dimension hid_size 2. z_logstd: a trainable variable, initialized to 0 shape (z_size,) Hint: use build_mlp """ z_mean = build_mlp( input_placeholder=state, output_size=z_size, scope=scope, n_layers=n_layers, size=hid_size, activation=tf.tanh, output_activation=None ) z_logstd = tf.Variable(initial_value=np.zeros(shape=(int(z_size), ), dtype=np.float32), trainable=True) return tfp.distributions.MultivariateNormalDiag(loc=z_mean, scale_diag=tf.exp(z_logstd))