original_docstring: 
          Performs hessian vector product on the train set in task with the provided vector
          
docstring: Performs hessian vector product on the train set in task with the provided vector
docstring_tokens: Performs hessian vector product on the train set in task with the provided vector
code: def hessian_vector_product(self, storage, last_batch_indices, vector):
          """
          Performs hessian vector product on the train set in task with the provided vector
          """
          states, actions, log_probs_old, returns, advantages = storage.cat(['s', 'a', 'log_pi_a', 'ret', 'adv'])
          actions = actions.detach()
          log_probs_old = log_probs_old.detach()
          advantages = (advantages - advantages.mean()) / advantages.std()
  
          policy_loss, _, _ = self.get_loss(self.inner_network,
                                            last_batch_indices,
                                            states, actions,
                                            log_probs_old,
                                            returns,
                                            advantages)
          policy_grad = torch.autograd.grad(policy_loss, self.inner_network.actor_params, create_graph=True)
          flat_grad = torch.cat([g.contiguous().view(-1) for g in policy_grad])
          vec = to_device(vector, self.config.use_gpu)
          h = torch.sum(flat_grad * vec)
  
          hvp = torch.autograd.grad(h, self.inner_network.actor_params, retain_graph=True)
  
          hvp_flat = torch.cat([g.contiguous().view(-1) for g in hvp])
          return hvp_flat
code_tokens: def hessian_vector_product ( self , storage , last_batch_indices , vector ) : states , actions , log_probs_old , returns , advantages = storage . cat ( [ 's' , 'a' , 'log_pi_a' , 'ret' , 'adv' ] ) actions = actions . detach ( ) log_probs_old = log_probs_old . detach ( ) advantages = ( advantages - advantages . mean ( ) ) / advantages . std ( ) policy_loss , _ , _ = self . get_loss ( self . inner_network , last_batch_indices , states , actions , log_probs_old , returns , advantages ) policy_grad = torch . autograd . grad ( policy_loss , self . inner_network . actor_params , create_graph = True ) flat_grad = torch . cat ( [ g . contiguous ( ) . view ( - 1 ) for g in policy_grad ] ) vec = to_device ( vector , self . config . use_gpu ) h = torch . sum ( flat_grad * vec ) hvp = torch . autograd . grad ( h , self . inner_network . actor_params , retain_graph = True ) hvp_flat = torch . cat ( [ g . contiguous ( ) . view ( - 1 ) for g in hvp ] ) return hvp_flat
short_docstring: Performs hessian vector product on the train set in task with the provided vector
short_docstring_tokens: Performs hessian vector product on the train set in task with the provided vector
comment: """
          Performs hessian vector product on the train set in task with the provided vector
          """