Replies: 2 comments
-
Thank you for posting this. The current Step-by-Step Solution
import torch
teacher_ckpt_path = "/path/to/teacher_checkpoint.pt"
teacher_weights = torch.load(teacher_ckpt_path)["model"]
from isaaclab_rl.rsl_rl.distillation import StudentTeacher
class CustomStudentTeacher(StudentTeacher):
def __init__(self, teacher_weights, **kwargs):
super().__init__(**kwargs)
# Load weights into the teacher network
self.teacher.load_state_dict(teacher_weights)
from isaaclab_rl.rsl_rl.distillation_cfg import RslRlDistillationStudentTeacherCfg
@configclass
class CustomDistillationCfg(RslRlDistillationStudentTeacherCfg):
teacher_model_path: str = MISSING # Add this field
# Load teacher weights
teacher_weights = torch.load(cfg.policy.teacher_model_path)["model"]
# Create policy with pre-trained teacher
policy = CustomStudentTeacher(
teacher_weights=teacher_weights,
hidden_dims=cfg.policy.student_hidden_dims,
activation=cfg.policy.activation
) Key Implementation Notes
Why This WorksThe RSL-RL distillation algorithm expects the teacher network to be initialized before training. By manually loading weights into the teacher network during policy construction, you satisfy this requirement while maintaining the student network's trainable parameters23.
References Footnotes |
Beta Was this translation helpful? Give feedback.
-
Hi @pumfish! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
Hi, I'm learning to use the RSL-RL Distillation in IsaacLab
I first check source/isaaclab_rl/isaaclab_rl/rsl_rl/rl_cfg.py, and find that
IsaacLab/source/isaaclab_rl/isaaclab_rl/rsl_rl/rl_cfg.py
Lines 150 to 154 in 28ed0bb
Then I checked source/isaaclab_rl/isaaclab_rl/rsl_rl/distillation_cfg.py, but I noticed that
RslRlDistillationStudentTeacherCfg
doesn't include parameters for loading pre-trained teacher model weights - it only contains the hidden layer lists for both teacher and student networks.IsaacLab/source/isaaclab_rl/isaaclab_rl/rsl_rl/distillation_cfg.py
Lines 31 to 35 in 28ed0bb
How should I load the pre-trained teacher network? Or, how does IsaacLab's wrapped policy configuration set up the
Distillation
in RSL-RL?https://github.com/leggedrobotics/rsl_rl/blob/750e84566d91877a8bbabc7971578be24429bca8/rsl_rl/algorithms/distillation.py#L16-L20
Beta Was this translation helpful? Give feedback.
All reactions