def testDpgGradient(self):
    """Gradient of loss w.r.t. actor network parameter w_s is correct."""
    with self.test_session() as sess:
      weight_gradient = tf.gradients(self.loss, self.w_s)
      sess.run(tf.global_variables_initializer())
      value_dpg_gradient, value_s_tm1, value_w = sess.run(
          [weight_gradient[0], self.s_tm1, self.w])
      true_grad = self.calculateTrueGradient(value_w, value_s_tm1)
      self.assertAllClose(value_dpg_gradient, true_grad)
Gradient of loss w.r.t. actor network parameter w_s is correct.
trfl/dpg_ops_test.py