Download tests/test_shape_issue.py from TRuCAL-Labs/TRuCAL: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/datasets/TRuCAL-Labs/TRuCAL/resolve/main/tests/test_shape_issue.py
- Command line
-
hf download hf://datasets/TRuCAL-Labs/TRuCAL/tests/test_shape_issue.py
-
curl -L -o test_shape_issue.py https://huggingface.co/datasets/TRuCAL-Labs/TRuCAL/resolve/main/tests/test_shape_issue.py
1.54 kB
| import torch | |
| from components.tiny_confessional_layer import TinyConfessionalLayer | |
| def diagnose_shape_issue(): | |
| """Diagnose the shape mismatch issue in TinyConfessionalLayer""" | |
| print("🔍 Diagnosing shape issue...") | |
| # Test with the exact parameters from the error | |
| d_model = 512 | |
| model = TinyConfessionalLayer(d_model=d_model) | |
| # Create input with proper dimensions (batch=1, seq=10, d_model=512) | |
| 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}") | |
| # Test forward pass step by step | |
| y_state = torch.zeros_like(x) | |
| z_state = torch.zeros_like(x) | |
| # Think step | |
| 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 step | |
| 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() | |