File size: 798 Bytes
b4396f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3
"""E1 fix 1: zero-init skill_embed + skill_pos (arm-D precedent:
new pathway is exactly inert at init; s == 0, Q init == D init)."""
from pathlib import Path

P = (Path.home() / "lerobot/src/lerobot/policies/sera_vla_v3" /
     "modeling_sera_vla_v3.py")
text = P.read_text()
old = ("        self.skill_embed = nn.Linear(4, 512)\n"
       "        self.skill_pos = nn.Parameter(torch.randn(8, 512) * 0.02)\n")
new = ("        self.skill_embed = nn.Linear(4, 512)\n"
       "        nn.init.zeros_(self.skill_embed.weight)\n"
       "        nn.init.zeros_(self.skill_embed.bias)\n"
       "        self.skill_pos = nn.Parameter(torch.zeros(8, 512))\n")
assert text.count(old) == 1, f"anchor count {text.count(old)}"
P.write_text(text.replace(old, new))
print("fix1 applied")