Spaces:
Runtime error
Runtime error
Download models/transformer/module/positionwise_feedforward.py from JingyuanLtd/LLM-fastAPI: direct link, hf CLI and curl.
- Browser
- Download file 455 Bytes
-
https://huggingface.co/spaces/JingyuanLtd/LLM-fastAPI/resolve/main/models/transformer/module/positionwise_feedforward.py
- Command line
-
hf download hf://spaces/JingyuanLtd/LLM-fastAPI/models/transformer/module/positionwise_feedforward.py
-
curl -L -o positionwise_feedforward.py https://huggingface.co/spaces/JingyuanLtd/LLM-fastAPI/resolve/main/models/transformer/module/positionwise_feedforward.py
455 Bytes
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| class PositionwiseFeedForward(nn.Module): | |
| "Implements FFN equation." | |
| def __init__(self, d_model, d_ff, dropout=0.1): | |
| super(PositionwiseFeedForward, self).__init__() | |
| self.w_1 = nn.Linear(d_model, d_ff) | |
| self.w_2 = nn.Linear(d_ff, d_model) | |
| self.dropout = nn.Dropout(dropout) | |
| def forward(self, x): | |
| return self.w_2(self.dropout(F.relu(self.w_1(x)))) | |