class_docstr: Unit tests for policy gradient.
class_docstr_tok: ["Unit","tests","for","policy","gradient","."]
code: def test_process_accumulated_trajectory(self):
      action_space = spaces.Discrete(2)
      observation_space = spaces.Box(0, 1, (1,))
      sut = ActorCritic("", observation_space, action_space)
  
      # Set up.
      self._setup_trajectory(sut)
  
      # Call test method.
      sut._process_accumulated_trajectory(False)
  
      # Verify results.
      self.assertEqual(len(sut._trajectory_rewards), 0)
      self.assertEqual(len(sut._trajectory_actions), 0)
      self.assertEqual(len(sut._trajectory_states), 0)
  
      np.testing.assert_array_equal(
          sut._input_buffer,
          [np.array([0.1], np.float32), np.array([0.2], np.float32)],
      )
      # For unknown reason, got [2.9974999999999996] instead of [2.9975] for
      # the following testcase, therefore use assert_array_almost_equal.
      np.testing.assert_array_almost_equal(
          sut._value_network_output_buffer,
          [
              [2.9975],  # 3.05 * 0.95 + 0.1
              [3.05],  # 3 (initial_r) * 0.95 + 0.2
          ],
      )
      np.testing.assert_array_equal(
          sut._policy_network_output_buffer,
          [np.array([1, 0], np.float32), np.array([0, 1], np.float32)],
      )
      np.testing.assert_array_almost_equal(
          sut._policy_network_weight_buffer,
          [[0.9975], [2.05]],  # 2.9975 - 2  # 3.05 - 1
      )
  
imports: import unittest
  import cntk.contrib.deeprl.tests.spaces
  import numpy
  from cntk.contrib.deeprl.agent.policy_gradient import ActorCritic
  from cntk.layers import Dense
  from cntk.losses import cross_entropy_with_softmax
  from cntk.ops import input_variable, placeholder
label_desc: Use image node_id 10 for calling the PolicyGradientTest obj's underlying member method code with example usage: obj.test_process_accumulated_trajectory() without return types