Closed norci closed 3 years ago
See also: https://arxiv.org/abs/1808.09940 "We also conduct intensive experiments in China Stock market and show that PG is more desirable in financial market than DDPG and PPO, although both of them are more advanced. "
I think PG is useful in some circumstances, although it's simpler than DDPG.
I tried to implement PG in this framework, but it is too complex for me.
I've implemented it before. But that's a long time ago. I'll take a look at it this weekend.
I'm sorry that I may not have enough time to work on this issue until the next month due to some personal issues.
I'll explain the implementation details here in case you'd like to try this by yourself:
First, we may need to have an (Added in RLCore)ElasticCompact**Trajectory
like structure for efficiency.
Circular*Trajectory
here because its capacity is constant. In REINFORCE algorithm, we need to sample a complete trajectory and split it into batches to update the policy.Vector
as the container instead of ElasticArray
. I guess there isn't too much performance difference between them for the REINFORCE algorithm. But unfortunately, I haven't exported some aliases like Vector*Trajectory
in RLCore. (Also you need to wrap it in a EpisodicTrajectory)Then the rest is simple, we update the policy only at the end of an episode, randomly select different batches and update the inner approximator
. You are encouraged to read the implementation of PPO
for similar implementation.
Ideally, the REINFORCE algorithm should also support tabular cases, https://github.com/JuliaReinforcementLearning/ReinforcementLearningAnIntroduction.jl/blob/master/src/extensions/policies/reinforce_policy.jl . But we can make it into another PR.
By the way, if you need the implementation similar to the one in openai/spinningup, then you need to dispatch the update!
method based on the type of the inner approximator.
thanks for your guidance. I'd like to implement this algo, and this project is awesome, I like it. But I'm a beginner in Julia & RL, so give me some time.
Cool! No hurry.
I just tagged a new release of RLCore@v0.4.3. Now you should have all the necessary components to implement it.
Doc:
Implementations:
https://github.com/PaddlePaddle/PARL/blob/develop/parl/algorithms/torch/policy_gradient.py
https://github.com/thu-ml/tianshou/blob/master/tianshou/policy/modelfree/pg.py