-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now, the model dimension can be different in the intermediate layers. This change applies to the ff module, and only in the encoder. Now, if the flag `ff_intermediate` is not None, the layers will look like this: ``` channels -> ff_dim -> ff_intermediate (For layer 1) ff_intermediate -> ff_dim -> ff_intermediate (For layers 2 to depth-1) ff_intermediate -> ff_dim -> channels (For layer depth) ``` As opposed to ``` channels -> ff_dim -> channels (For all layers) ```
- Loading branch information
Showing
2 changed files
with
52 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
import torch | ||
|
||
sys.path.insert(0, "../") | ||
from linformer_pytorch import Linformer | ||
|
||
model = Linformer( | ||
input_size=510, | ||
channels=21, | ||
dim_d=26, | ||
dim_k=61, | ||
dim_ff=32, | ||
nhead=4, | ||
depth=3, | ||
activation="relu", | ||
checkpoint_level="C1", | ||
parameter_sharing="none", | ||
k_reduce_by_layer=1, | ||
include_ff=True, | ||
convolution=True, | ||
ff_intermediate=64, | ||
) | ||
x = torch.randn(1, 510, 21) | ||
y = model(x) | ||
print(y) # (1, 512, 16) |
This file contains 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