Skip to content

I can't undestand why the net don't use the random sampled action_, but use the max action, According to policy grad definition, the net should  #5

Description

@wyz1074152339

Hello, why does the network perform the largest selected action (action) instead of randomly sampled actions (action_). According to the policy_grad algorithm, the actions performed by the network are randomly sampled, but the network executes in your program It is the maximum action, but the probability is stored at random, and your program says that action and action_ are the same value, but during the debugging process, I found that it’s not the same value. Something may happen when action is 2. action_ is 7 or other, can you answer it?
if args.cuda:
action = np.argmax(fc6_out.detach().cpu().numpy()) # TODO: really okay to detach?
action_prob = fc6_out.detach().cpu().numpy()[0][action]
else:
action = np.argmax(fc6_out.detach().numpy()) # TODO: really okay to detach?
action_prob = fc6_out.detach().numpy()[0][action]

            m = Categorical(probs=fc6_out)
            action_ = m.sample()  # action and action_ are same value. Only differ in the type (int and tensor)

            self.log_probs_list.append(m.log_prob(action_).cpu().data.numpy())
            self.vid_idx_list.append(vid_idx)

            self.action_list.append(action)
            # TODO: saving action_prob_list takes cuda memory
            # self.action_prob_list.append(action_prob)

            new_state, reward, done, info = self.env.step(action)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions