class_docstr: Gaussian MLP Baseline with Model.
  
  It fits the input data to a gaussian distribution estimated by
  a MLP.
  
  Args:
      env_spec (garage.envs.env_spec.EnvSpec): Environment specification.
      subsample_factor (float): The factor to subsample the data. By
          default it is 1.0, which means using all the data.
      num_seq_inputs (float): Number of sequence per input. By default
          it is 1.0, which means only one single sequence.
      name (str): Name of baseline.
      hidden_sizes (list[int]): Output dimension of dense layer(s) for
          the MLP for mean. For example, (32, 32) means the MLP consists
          of two hidden layers, each with 32 hidden units.
      hidden_nonlinearity (Callable): Activation function for intermediate
          dense layer(s). It should return a tf.Tensor. Set it to
          None to maintain a linear activation.
      hidden_w_init (Callable): Initializer function for the weight
          of intermediate dense layer(s). The function should return a
          tf.Tensor.
      hidden_b_init (Callable): Initializer function for the bias
          of intermediate dense layer(s). The function should return a
          tf.Tensor.
      output_nonlinearity (Callable): Activation function for output dense
          layer. It should return a tf.Tensor. Set it to None to
          maintain a linear activation.
      output_w_init (Callable): Initializer function for the weight
          of output dense layer(s). The function should return a
          tf.Tensor.
      output_b_init (Callable): Initializer function for the bias
          of output dense layer(s). The function should return a
          tf.Tensor.
      optimizer (garage.tf.Optimizer): Optimizer for minimizing the negative
          log-likelihood.
      optimizer_args (dict): Arguments for the optimizer. Default is None,
          which means no arguments.
      use_trust_region (bool): Whether to use trust region constraint.
      max_kl_step (float): KL divergence constraint for each iteration.
      learn_std (bool): Is std trainable.
      init_std (float): Initial value for std.
      adaptive_std (bool): Is std a neural network. If False, it will be a
          parameter.
      std_share_network (bool): Boolean for whether mean and std share
          the same network.
      std_hidden_sizes (list[int]): Output dimension of dense layer(s) for
          the MLP for std. For example, (32, 32) means the MLP consists
          of two hidden layers, each with 32 hidden units.
      std_nonlinearity (Callable): Nonlinearity for each hidden layer in
          the std network.
      layer_normalization (bool): Bool for using layer normalization or not.
      normalize_inputs (bool): Bool for normalizing inputs or not.
      normalize_outputs (bool): Bool for normalizing outputs or not.
      subsample_factor (float): The factor to subsample the data. By default
          it is 1.0, which means using all the data.
class_docstr_tok: ["Gaussian","MLP","Baseline","with","Model",".","It","fits","the","input","data","to","a","gaussian","distribution","estimated","by","a","MLP",".","Args",":","env_spec","(","garage.envs.env_spec.EnvSpec",")",":","Environment","specification",".","subsample_factor","(","float",")",":","The","factor","to","subsample","the","data",".","By","default","it","is","1.0",",","which","means","using","all","the","data",".","num_seq_inputs","(","float",")",":","Number","of","sequence","per","input",".","By","default","it","is","1.0",",","which","means","only","one","single","sequence",".","name","(","str",")",":","Name","of","baseline",".","hidden_sizes","(","list","[","int","]",")",":","Output","dimension","of","dense","layer","(","s",")","for","the","MLP","for","mean",".","For","example",",","(","32",",","32",")","means","the","MLP","consists","of","two","hidden","layers",",","each","with","32","hidden","units",".","hidden_nonlinearity","(","Callable",")",":","Activation","function","for","intermediate","dense","layer","(","s",")",".","It","should","return","a","tf.Tensor",".","Set","it","to","None","to","maintain","a","linear","activation",".","hidden_w_init","(","Callable",")",":","Initializer","function","for","the","weight","of","intermediate","dense","layer","(","s",")",".","The","function","should","return","a","tf.Tensor",".","hidden_b_init","(","Callable",")",":","Initializer","function","for","the","bias","of","intermediate","dense","layer","(","s",")",".","The","function","should","return","a","tf.Tensor",".","output_nonlinearity","(","Callable",")",":","Activation","function","for","output","dense","layer",".","It","should","return","a","tf.Tensor",".","Set","it","to","None","to","maintain","a","linear","activation",".","output_w_init","(","Callable",")",":","Initializer","function","for","the","weight","of","output","dense","layer","(","s",")",".","The","function","should","return","a","tf.Tensor",".","output_b_init","(","Callable",")",":","Initializer","function","for","the","bias","of","output","dense","layer","(","s",")",".","The","function","should","return","a","tf.Tensor",".","optimizer","(","garage.tf.Optimizer",")",":","Optimizer","for","minimizing","the","negative","log-likelihood",".","optimizer_args","(","dict",")",":","Arguments","for","the","optimizer",".","Default","is","None",",","which","means","no","arguments",".","use_trust_region","(","bool",")",":","Whether","to","use","trust","region","constraint",".","max_kl_step","(","float",")",":","KL","divergence","constraint","for","each","iteration",".","learn_std","(","bool",")",":","Is","std","trainable",".","init_std","(","float",")",":","Initial","value","for","std",".","adaptive_std","(","bool",")",":","Is","std","a","neural","network",".","If","False",",","it","will","be","a","parameter",".","std_share_network","(","bool",")",":","Boolean","for","whether","mean","and","std","share","the","same","network",".","std_hidden_sizes","(","list","[","int","]",")",":","Output","dimension","of","dense","layer","(","s",")","for","the","MLP","for","std",".","For","example",",","(","32",",","32",")","means","the","MLP","consists","of","two","hidden","layers",",","each","with","32","hidden","units",".","std_nonlinearity","(","Callable",")",":","Nonlinearity","for","each","hidden","layer","in","the","std","network",".","layer_normalization","(","bool",")",":","Bool","for","using","layer","normalization","or","not",".","normalize_inputs","(","bool",")",":","Bool","for","normalizing","inputs","or","not",".","normalize_outputs","(","bool",")",":","Bool","for","normalizing","outputs","or","not",".","subsample_factor","(","float",")",":","The","factor","to","subsample","the","data",".","By","default","it","is","1.0",",","which","means","using","all","the","data","."]
code: def _initialize(self):
      input_var = tf.compat.v1.placeholder(
          tf.float32, shape=(None,) + self._input_shape
      )
      ys_var = tf.compat.v1.placeholder(
          dtype=tf.float32, name="ys", shape=(None, self._output_dim)
      )
  
      self._old_network = self._old_model.build(input_var)
      (
          norm_dist,
          norm_mean,
          norm_log_std,
          _,
          mean,
          _,
          self._x_mean,
          self._x_std,
          self._y_mean,
          self._y_std,
      ) = self.build(input_var).outputs
  
      normalized_ys_var = (ys_var - self._y_mean) / self._y_std
      old_normalized_dist = self._old_network.normalized_dist
  
      mean_kl = tf.reduce_mean(
          old_normalized_dist.kl_divergence(norm_dist)
      )
      loss = -tf.reduce_mean(norm_dist.log_prob(normalized_ys_var))
      self._f_predict = compile_function([input_var], mean)
      optimizer_args = dict(
          loss=loss,
          target=self,
          network_outputs=[norm_mean, norm_log_std],
      )
      if self._use_trust_region:
          optimizer_args["leq_constraint"] = (
              mean_kl,
              self._max_kl_step,
          )
      optimizer_args["inputs"] = [input_var, ys_var]
      with tf.name_scope("update_opt"):
          self._optimizer.update_opt(**optimizer_args)
  
imports: from dowel import tabular
  import numpy
  import tensorflow
  from garage import make_optimizer
  from garage.experiment import deterministic
  from garage.np.baselines import Baseline
  from garage.tf import compile_function
  from garage.tf.baselines.gaussian_mlp_baseline_model import GaussianMLPBaselineModel
  from garage.tf.optimizers import LBFGSOptimizer, PenaltyLBFGSOptimizer
label_desc: Use image node_id 2 for calling the GaussianMLPBaseline obj's underlying member method code with example usage: obj._initialize() without return types