def calc_v(self, x, net=None, use_cache=True): ''' Forward-pass to calculate the predicted state-value from critic_net. ''' if self.shared: # output: policy, value if use_cache: # uses cache from calc_pdparam to prevent double-pass v_pred = self.v_pred else: net = self.net if net is None else net v_pred = net(x)[-1].view(-1) else: net = self.critic_net if net is None else net v_pred = net(x).view(-1) return v_pred
def calc_pdparam(self, x, net=None): ''' The pdparam will be the logits for discrete prob. dist., or the mean and std for continuous prob. dist. ''' net = self.net if net is None else net pdparam = net(x) return pdparam
def calc_pdparam(self, x, net=None): ''' To get the pdparam for action policy sampling, do a forward pass of the appropriate net, and pick the correct outputs. The pdparam will be the logits for discrete prob. dist., or the mean and std for continuous prob. dist. ''' net = self.net if net is None else net pdparam = net(x) return pdparam