| |
| import h5py |
| import tensorflow as tf |
| import json |
|
|
| print("π Diagnosing hybrid_model.keras...") |
|
|
| |
| print("\n1. HDF5 File Structure:") |
| with h5py.File('hybrid_model.keras', 'r') as f: |
| print("Top-level keys:", list(f.keys())) |
| |
| |
| if 'model_config' in f: |
| config = f['model_config'][()] |
| if isinstance(config, bytes): |
| config = config.decode('utf-8') |
| |
| |
| try: |
| model_config = json.loads(config) |
| print("\n2. Model Configuration:") |
| print(f" Model class: {model_config.get('class_name', 'Unknown')}") |
| print(f" Config keys: {list(model_config.get('config', {}).keys())}") |
| |
| |
| if 'layers' in model_config.get('config', {}): |
| layers = model_config['config']['layers'] |
| print(f"\n3. Model Layers ({len(layers)} total):") |
| for i, layer in enumerate(layers): |
| class_name = layer.get('class_name', 'Unknown') |
| name = layer.get('config', {}).get('name', 'No name') |
| print(f" {i:3d}: {class_name:30s} - {name}") |
| except: |
| print(" Could not parse model config") |
| |
| |
| if 'model_weights' in f: |
| print("\n4. Model Weights:") |
| weight_layers = list(f['model_weights'].keys()) |
| print(f" Weight groups: {weight_layers[:10]}") |
| |
| |
| print("\n5. Attempting Keras load...") |
| try: |
| model = tf.keras.models.load_model('hybrid_model.keras', compile=False) |
| print(f" β
Success! Model loaded") |
| print(f" Input shape: {model.input_shape}") |
| print(f" Output shape: {model.output_shape}") |
| print(f" Layers: {len(model.layers)}") |
| |
| |
| print("\n Layer Names:") |
| for i, layer in enumerate(model.layers[:10]): |
| print(f" {i}: {layer.name} ({layer.__class__.__name__})") |
| |
| except Exception as e: |
| print(f" β Failed: {e}") |