Views
No views yet
PandaPickAndPlace-v3 environment
from panda-gym, using
stable-baselines3.PandaPickAndPlace-v3 is a sparse-reward, goal-conditioned task: the agent gets
-1 reward every step until the object reaches the target position, 0 otherwise.
Plain off-policy RL (SAC/TD3/DDPG) essentially never learns here, because a random
policy almost never reaches the goal, so almost every trajectory carries the same
uninformative reward signal.g but happened to move the object to some other position g',
HER stores an extra transition where g' is treated as if it had been the goal all
along, with the reward recomputed accordingly. This turns every episode into a
source of positive learning signal, "success at a different goal", even when the
original goal wasn't reached.Mean reward = -20.80 +/- 19.18-50 = never reached goal, values closer to
0 = faster successful pick-and-place)
| Hyperparameter | Value |
|---|---|
| Algorithm | SAC |
| Replay buffer | HerReplayBuffer |
n_sampled_goal | 4 |
goal_selection_strategy | future |
learning_starts | 1000 |
learning_rate | 1e-3 |
buffer_size | 1,000,000 |
batch_size | 1024 |
gamma | 0.95 |
tau | 0.05 |
net_arch | [512, 512, 512] |
n_critics | 2 |
n_envs | 8 |
| Total timesteps | 1,000,000 |
| Observation normalization | VecNormalize(norm_obs=True, norm_reward=False) |
learning_starts must exceed the environment's max episode length (50 steps) so
that HER always has at least one complete episode to relabel before the first
gradient update — otherwise SB3 raises RuntimeError: Unable to sample before the end of the first episode.train.py.pip install stable-baselines3 sb3-contrib huggingface_sb3 panda-gym1import gymnasium as gym
2import panda_gym
3from huggingface_sb3 import load_from_hub
4from stable_baselines3 import SAC
5from stable_baselines3.common.vec_env import DummyVecEnv, VecNormalize
6
7repo_id = "monshinawatra/sac-her-PandaPickAndPlace-v3"
8
9checkpoint = load_from_hub(repo_id, "sac-her-PandaPickAndPlace-v3.zip")
10stats_path = load_from_hub(repo_id, "vec_normalize.pkl")
11
12env = DummyVecEnv([lambda: gym.make("PandaPickAndPlace-v3", render_mode="human")])
13env = VecNormalize.load(stats_path, env)
14env.training = False
15env.norm_reward = False
16
17model = SAC.load(checkpoint, env=env)
18
19obs = env.reset()
20for _ in range(1000):
21 action, _ = model.predict(obs, deterministic=True)
22 obs, reward, done, info = env.step(action)
23 env.render()inference.py.PandaPickAndPlace-v3Dict (observation, achieved_goal, desired_goal) — requires MultiInputPolicyBox(4,) — 3D end-effector displacement + gripper