def test_param_values(self, obs_dim): box_env = TfEnv(DummyBoxEnv(obs_dim=obs_dim)) with mock.patch(('garage.tf.baselines.' 'gaussian_mlp_baseline_with_model.' 'GaussianMLPRegressorWithModel'), new=SimpleGaussianMLPRegressor): gmb = GaussianMLPBaselineWithModel(env_spec=box_env.spec) new_gmb = GaussianMLPBaselineWithModel( env_spec=box_env.spec, name='GaussianMLPBaselineWithModel2') old_param_values = gmb.get_param_values() new_param_values = new_gmb.get_param_values() assert not np.array_equal(old_param_values, new_param_values) new_gmb.set_param_values(old_param_values) new_param_values = new_gmb.get_param_values() assert np.array_equal(old_param_values, new_param_values)
def test_param_values(self, obs_dim): box_env = TfEnv(DummyBoxEnv(obs_dim=obs_dim)) with mock.patch(('garage.tf.baselines.' 'gaussian_mlp_baseline_with_model.' 'GaussianMLPRegressorWithModel'), new=SimpleGaussianMLPRegressor): gmb = GaussianMLPBaselineWithModel(env_spec=box_env.spec) new_gmb = GaussianMLPBaselineWithModel( env_spec=box_env.spec, name='GaussianMLPBaselineWithModel2') # Manual change the parameter of GaussianMLPBaselineWithModel with tf.variable_scope('GaussianMLPBaselineWithModel', reuse=True): return_var = tf.get_variable('SimpleGaussianMLPModel/return_var') return_var.load(1.0) old_param_values = gmb.get_param_values() new_param_values = new_gmb.get_param_values() assert not np.array_equal(old_param_values, new_param_values) new_gmb.set_param_values(old_param_values) new_param_values = new_gmb.get_param_values() assert np.array_equal(old_param_values, new_param_values)