holy fuking shit
This commit is contained in:
@@ -12,7 +12,8 @@ from mcm26b.rl.features import build_observation
|
||||
|
||||
def main():
|
||||
root = Path('output/rl/review-20260911')
|
||||
records = json.loads((root/'evaluation/validation/final/results.json').read_text(encoding='utf-8'))
|
||||
records = json.loads((root/'evaluation/validation/final/results.json')
|
||||
.read_text(encoding='utf-8'))
|
||||
rng = np.random.default_rng(20260911)
|
||||
comparisons = {}
|
||||
for problem in (3,4):
|
||||
@@ -46,13 +47,16 @@ def main():
|
||||
bc = {}
|
||||
for problem in (3,4):
|
||||
# 使用旧检查点和原始专家输入,比对原ReLU网络与拷贝后的Tanh网络。
|
||||
checkpoint = torch.load(f'output/rl/bc/q{problem}_bc.pt',map_location='cpu',weights_only=True)
|
||||
checkpoint = torch.load(f'output/rl/bc/q{problem}_bc.pt',map_location='cpu',
|
||||
weights_only=True)
|
||||
data = np.load(f'output/rl/bc/q{problem}_expert.npz',allow_pickle=False)
|
||||
x = torch.from_numpy(data['obs'][::max(1,len(data['obs'])//1000)].copy())
|
||||
def network(activation):
|
||||
|
||||
def network(activation, checkpoint=checkpoint):
|
||||
net = torch.nn.Sequential(torch.nn.Linear(401,128),activation(),
|
||||
torch.nn.Linear(128,128),activation(),torch.nn.Linear(128,60))
|
||||
net.load_state_dict({k.removeprefix('net.'):v for k,v in checkpoint['state_dict'].items()})
|
||||
state = {k.removeprefix('net.'):v for k,v in checkpoint['state_dict'].items()}
|
||||
net.load_state_dict(state)
|
||||
return net
|
||||
with torch.no_grad():
|
||||
before,after=network(torch.nn.ReLU)(x),network(torch.nn.Tanh)(x)
|
||||
@@ -63,9 +67,11 @@ def main():
|
||||
limitations='置信区间仅重采样固定模型的场景,不覆盖训练随机种子不确定性。',
|
||||
code_sha256={str(p):hashlib.sha256(p.read_bytes()).hexdigest()
|
||||
for p in sorted(Path('src/mcm26b/rl').glob('*.py'))})
|
||||
(root/'review_evidence.json').write_text(json.dumps(report,ensure_ascii=False,indent=2),encoding='utf-8')
|
||||
(root/'review_evidence.json').write_text(
|
||||
json.dumps(report,ensure_ascii=False,indent=2),encoding='utf-8')
|
||||
print(json.dumps(dict(comparisons=comparisons,feature_probe=features,bc_probe=bc,
|
||||
official=[dict(case=r['case_code'],passed=r['passed']) for r in official]),indent=2))
|
||||
official=[dict(case=r['case_code'],passed=r['passed'])
|
||||
for r in official]),indent=2))
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
|
||||
Reference in New Issue
Block a user