File size: 1,870 Bytes
9633935
5c2ff29
 
 
 
9633935
 
 
 
5c2ff29
 
9633935
 
 
 
 
 
 
 
 
 
 
 
 
5c2ff29
 
 
 
 
9633935
5c2ff29
 
 
 
 
 
9633935
 
 
 
 
5c2ff29
 
9633935
 
 
 
5c2ff29
9633935
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Sweep PP direct residual scale."""
import subprocess
import json
import re

predict_path = "/home/coder/experiments/2026-04-12-342000-pp-residual-tune/predict.py"

with open(predict_path, 'r') as f:
    original = f.read()

results = {}
for scale in [0.96, 0.97, 0.98, 0.99, 1.00, 1.01, 1.02, 1.03, 1.04]:
    content = original
    # Replace PP direct calls (both orig and flipped)
    content = re.sub(
        r'_predict_8frames_direct\(ens\.models\["pole_position"\], context_tensor, last_tensor\)',
        f'_predict_8frames_direct(ens.models["pole_position"], context_tensor, last_tensor, residual_scale={scale})',
        content
    )
    content = re.sub(
        r'_predict_8frames_direct\(ens\.models\["pole_position"\], context_flipped, last_flipped\)',
        f'_predict_8frames_direct(ens.models["pole_position"], context_flipped, last_flipped, residual_scale={scale})',
        content
    )

    with open(predict_path, 'w') as f:
        f.write(content)

    result = subprocess.run(
        ['python', 'task/score.py', '--model_path', '/home/coder/experiments/2026-04-12-342000-pp-residual-tune'],
        capture_output=True, text=True, cwd='/home/coder'
    )

    for line in result.stdout.strip().split('\n'):
        if '"score"' in line:
            data = json.loads(line)
            results[scale] = {
                'score': data['score'],
                'pp': data['per_game']['pole_position']['ssim']
            }
            print(f"Scale {scale}: overall={data['score']:.4f} pp={data['per_game']['pole_position']['ssim']:.4f}")
            break

# Restore
with open(predict_path, 'w') as f:
    f.write(original)

print("\n=== Summary ===")
best_scale = max(results.keys(), key=lambda s: results[s]['pp'])
print(f"Best PP scale: {best_scale} with pp={results[best_scale]['pp']:.4f}, overall={results[best_scale]['score']:.4f}")