class_docstr: Test class for ContinuousMLPPolicy
class_docstr_tok: ["Test","class","for","ContinuousMLPPolicy"]
docstr: Test if ContinuousMLPPolicy is pickleable
docstr_tok: ["Test","if","ContinuousMLPPolicy","is","pickleable"]
code: def test_is_pickleable(self, obs_dim, action_dim):
      """Test if ContinuousMLPPolicy is pickleable"""
      env = GymEnv(DummyBoxEnv(obs_dim=obs_dim, action_dim=action_dim))
      policy = ContinuousMLPPolicy(env_spec=env.spec)
      state_input = tf.compat.v1.placeholder(
          tf.float32, shape=(None, np.prod(obs_dim))
      )
      outputs = policy.build(state_input, name="policy")
      env.reset()
      obs = env.step(1).observation
  
      with tf.compat.v1.variable_scope(
          "ContinuousMLPPolicy", reuse=True
      ):
          bias = tf.compat.v1.get_variable("mlp/hidden_0/bias")
      # assign it to all one
      bias.load(tf.ones_like(bias).eval())
      output1 = self.sess.run(
          [outputs], feed_dict={state_input: [obs.flatten()]}
      )
  
      p = pickle.dumps(policy)
      with tf.compat.v1.Session(graph=tf.Graph()) as sess:
          policy_pickled = pickle.loads(p)
          state_input = tf.compat.v1.placeholder(
              tf.float32, shape=(None, np.prod(obs_dim))
          )
          outputs = policy_pickled.build(state_input, name="policy")
          output2 = sess.run(
              [outputs], feed_dict={state_input: [obs.flatten()]}
          )
          assert np.array_equal(output1, output2)
  
file_path: garage/tests/garage/tf/policies/test_continuous_mlp_policy.py
imports: import pickle
  from unittest import mock
  import numpy
  import pytest
  import tensorflow
  from garage.envs import GymEnv
  from garage.tf.policies import ContinuousMLPPolicy
  from tests.fixtures import TfGraphTestCase
  from tests.fixtures.envs.dummy import DummyBoxEnv, DummyDictEnv
label_desc: Use image node_id 3 for calling the TestContinuousMLPPolicy obj's underlying member method code with example usage: obj.test_is_pickleable(obs_dim, action_dim) without return types