eesfeg commited on
Commit
810396d
·
1 Parent(s): 80dcb91
Files changed (1) hide show
  1. diagnose_model.py +58 -0
diagnose_model.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Save as: diagnose_model.py
2
+ import h5py
3
+ import tensorflow as tf
4
+ import json
5
+
6
+ print("🔍 Diagnosing hybrid_model.keras...")
7
+
8
+ # 1. Check file structure
9
+ print("\n1. HDF5 File Structure:")
10
+ with h5py.File('hybrid_model.keras', 'r') as f:
11
+ print("Top-level keys:", list(f.keys()))
12
+
13
+ # Check for model config
14
+ if 'model_config' in f:
15
+ config = f['model_config'][()]
16
+ if isinstance(config, bytes):
17
+ config = config.decode('utf-8')
18
+
19
+ # Try to parse JSON
20
+ try:
21
+ model_config = json.loads(config)
22
+ print("\n2. Model Configuration:")
23
+ print(f" Model class: {model_config.get('class_name', 'Unknown')}")
24
+ print(f" Config keys: {list(model_config.get('config', {}).keys())}")
25
+
26
+ # Print layers
27
+ if 'layers' in model_config.get('config', {}):
28
+ layers = model_config['config']['layers']
29
+ print(f"\n3. Model Layers ({len(layers)} total):")
30
+ for i, layer in enumerate(layers):
31
+ class_name = layer.get('class_name', 'Unknown')
32
+ name = layer.get('config', {}).get('name', 'No name')
33
+ print(f" {i:3d}: {class_name:30s} - {name}")
34
+ except:
35
+ print(" Could not parse model config")
36
+
37
+ # Check weights
38
+ if 'model_weights' in f:
39
+ print("\n4. Model Weights:")
40
+ weight_layers = list(f['model_weights'].keys())
41
+ print(f" Weight groups: {weight_layers[:10]}") # First 10
42
+
43
+ # Try to load with Keras
44
+ print("\n5. Attempting Keras load...")
45
+ try:
46
+ model = tf.keras.models.load_model('hybrid_model.keras', compile=False)
47
+ print(f" ✅ Success! Model loaded")
48
+ print(f" Input shape: {model.input_shape}")
49
+ print(f" Output shape: {model.output_shape}")
50
+ print(f" Layers: {len(model.layers)}")
51
+
52
+ # Show layer names
53
+ print("\n Layer Names:")
54
+ for i, layer in enumerate(model.layers[:10]): # First 10
55
+ print(f" {i}: {layer.name} ({layer.__class__.__name__})")
56
+
57
+ except Exception as e:
58
+ print(f" ❌ Failed: {e}")