-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_model.py
More file actions
38 lines (30 loc) · 1.16 KB
/
test_model.py
File metadata and controls
38 lines (30 loc) · 1.16 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
import torch
import torch.nn as nn
# Test script to analyze your model structure
def analyze_model():
try:
# Load the model
model_data = torch.load('graph_classifier_model.pth', map_location='cpu')
print("Model Analysis:")
print("=" * 40)
if isinstance(model_data, dict):
print("Model is a state dictionary")
print(f"Keys: {list(model_data.keys())}")
# Analyze layer structure
for key, tensor in model_data.items():
print(f"{key}: {tensor.shape}")
else:
print("Model is a complete model object")
print(f"Model type: {type(model_data)}")
# Try to get state dict
if hasattr(model_data, 'state_dict'):
state_dict = model_data.state_dict()
for key, tensor in state_dict.items():
print(f"{key}: {tensor.shape}")
print("\nModel loaded successfully!")
return True
except Exception as e:
print(f"Error loading model: {e}")
return False
if __name__ == "__main__":
analyze_model()