-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_checkpoint.py
More file actions
41 lines (29 loc) · 1.07 KB
/
Copy pathdebug_checkpoint.py
File metadata and controls
41 lines (29 loc) · 1.07 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
# Load checkpoint
#!/usr/bin/env python3
from pathlib import Path
import logging
import torch
"""
Debug Checkpoint Format
"""
def debug_checkpoint():
checkpoint_path = Path("test_checkpoints/best_model.pt")
if not checkpoint_path.exists():
logging.info("❌ Checkpoint not found")
return
logging.info("🔍 Debugging checkpoint format...")
checkpoint = torch.load(checkpoint_path, map_location="cpu")
logging.info("Checkpoint type: {type(checkpoint)}")
logging.info("Checkpoint content: {checkpoint}")
if isinstance(checkpoint, dict):
logging.info("\n📋 Dictionary keys:")
for _key in checkpoint:
logging.info(" - {key}: {type(checkpoint[key])}")
elif isinstance(checkpoint, tuple):
logging.info("\n📋 Tuple length: {len(checkpoint)}")
for __i, item in enumerate(checkpoint):
logging.info(" - Item {i}: {type(item)}")
if isinstance(item, dict):
logging.info(" Keys: {list(item.keys())}")
if __name__ == "__main__":
debug_checkpoint()