-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnose_latest.ps1
More file actions
62 lines (54 loc) · 2.14 KB
/
Copy pathdiagnose_latest.ps1
File metadata and controls
62 lines (54 loc) · 2.14 KB
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
52
53
54
55
56
57
58
59
60
61
62
# diagnose_latest.ps1
# -------------------
# Roll out the latest periodic PPO checkpoint with both stochastic and
# deterministic policies, write best.mp4 + all_runs.json under
# <run>/diagnose_<step>/ . Use this to peek at "what is the current
# policy actually doing" while training is still in flight.
#
# Usage:
# pwsh -ExecutionPolicy Bypass -File .\diagnose_latest.ps1
# pwsh -ExecutionPolicy Bypass -File .\diagnose_latest.ps1 -Seeds 5 -MaxSteps 1200
param(
[int]$Seeds = 3,
[int]$MaxSteps = 800,
[string]$RunDir = "",
[string]$Modes = "stochastic,deterministic"
)
$ErrorActionPreference = "Stop"
$projectRoot = "C:\Users\31660\mario-rl"
$python = Join-Path $projectRoot ".venv-gpu\Scripts\python.exe"
$renderer = Join-Path $projectRoot "render_best_checkpoint.py"
function Get-LatestPpoRunDir {
$candidates = Get-ChildItem (Join-Path $projectRoot "runs") -Directory -Filter "ppo_*" `
-ErrorAction SilentlyContinue
if (-not $candidates) { return $null }
$scored = foreach ($d in $candidates) {
$m = [regex]::Match($d.Name, "(\d{8}_\d{6})$")
if ($m.Success) {
[PSCustomObject]@{ Dir = $d; Stamp = $m.Groups[1].Value }
}
}
($scored | Sort-Object Stamp -Descending | Select-Object -First 1).Dir
}
if (-not $RunDir) {
$runDirObj = Get-LatestPpoRunDir
if (-not $runDirObj) { throw "no runs/ppo_* directory found" }
$RunDir = $runDirObj.FullName
}
$ckptDir = Join-Path $RunDir "run\models\checkpoints"
if (-not (Test-Path $ckptDir)) { throw "no checkpoints under $ckptDir" }
$latest = Get-ChildItem $ckptDir -Filter "mario_ppo_*_steps.zip" |
Sort-Object { [int](($_.BaseName -split "_")[2]) } -Descending |
Select-Object -First 1
if (-not $latest) { throw "no mario_ppo_*_steps.zip in $ckptDir" }
$outDir = Join-Path $RunDir "run\diagnose_$($latest.BaseName)"
Write-Host "checkpoint : $($latest.FullName)"
Write-Host "output_dir : $outDir"
Write-Host "seeds : $Seeds max_steps: $MaxSteps modes: $Modes"
Write-Host "---"
& $python $renderer `
--model $latest.FullName `
--seeds $Seeds `
--max-steps $MaxSteps `
--policy-modes $Modes `
--output-dir $outDir