| import torch |
| from components.tiny_confessional_layer import TinyConfessionalLayer |
|
|
| def diagnose_shape_issue(): |
| """Diagnose the shape mismatch issue in TinyConfessionalLayer""" |
| print("🔍 Diagnosing shape issue...") |
| |
| |
| d_model = 512 |
| model = TinyConfessionalLayer(d_model=d_model) |
| |
| |
| x = torch.randn(1, 10, d_model) |
| |
| print(f"Input shape: {x.shape}") |
| print(f"Think net first layer: {model.think_net[0].weight.shape}") |
| print(f"Act net first layer: {model.act_net[0].weight.shape}") |
| |
| |
| y_state = torch.zeros_like(x) |
| z_state = torch.zeros_like(x) |
| |
| |
| think_input = torch.cat([x, y_state, z_state], dim=-1) |
| print(f"\nThink input shape: {think_input.shape}") |
| print(f"Expected: (1, 10, {d_model*3}) = (1, 10, {3*d_model})") |
| |
| try: |
| z_state = model.think_net(think_input) |
| print("✅ Think step passed") |
| except Exception as e: |
| print(f"❌ Think step failed: {e}") |
| |
| |
| act_input = torch.cat([y_state, z_state], dim=-1) |
| print(f"\nAct input shape: {act_input.shape}") |
| print(f"Expected: (1, 10, {d_model*2}) = (1, 10, {2*d_model})") |
| |
| try: |
| y_state = model.act_net(act_input) |
| print("✅ Act step passed") |
| except Exception as e: |
| print(f"❌ Act step failed: {e}") |
|
|
| if __name__ == "__main__": |
| diagnose_shape_issue() |
|
|