Created
January 2, 2026 21:41
-
-
Save cjams/420e2f07093bd44385a035476cea11e1 to your computer and use it in GitHub Desktop.
Bengio deep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model = [ | |
| Embedding(device=device, num_embeddings=vocab_size, embedding_dim=embed_dim), | |
| Flatten(input_dim1=ctx_window, input_dim2=embed_dim), | |
| Linear(device=device, in_features=ctx_window*embed_dim, out_features=hidden_size, bias=True), | |
| Tanh(), | |
| Linear(device=device, in_features=hidden_size, out_features=hidden_size, bias=True), | |
| Tanh(), | |
| Linear(device=device, in_features=hidden_size, out_features=hidden_size, bias=True), | |
| Tanh(), | |
| Linear(device=device, in_features=hidden_size, out_features=hidden_size, bias=True), | |
| Tanh(), | |
| Linear(device=device, in_features=hidden_size, out_features=vocab_size, bias=True) | |
| ] | |
| params = [p for layer in model for p in layer.params()] | |
| # Enable gradients for the learnable parameters | |
| for p in params: | |
| p.requires_grad = True | |
| # Create RNG | |
| g = torch.Generator(device=device).manual_seed(42) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment