Spaces:
Sleeping
Sleeping
Download model.py from nullHawk/name_origin_detection: direct link, hf CLI and curl.
- Browser
- Download file 724 Bytes
-
https://huggingface.co/spaces/nullHawk/name_origin_detection/resolve/main/model.py
- Command line
-
hf download hf://spaces/nullHawk/name_origin_detection/model.py
-
curl -L -o model.py https://huggingface.co/spaces/nullHawk/name_origin_detection/resolve/main/model.py
724 Bytes
| import torch | |
| import torch.nn as nn | |
| class RNN(nn.Module): | |
| def __init__(self, input_size, hidden_size, output_size): | |
| super(RNN, self).__init__() | |
| self.hidden_size = hidden_size | |
| self.i2h = nn.Linear(input_size + hidden_size, hidden_size) | |
| self.i2o = nn.Linear(input_size + hidden_size, output_size) | |
| self.softmax = nn.LogSoftmax(dim=1) | |
| def forward(self, input_tensor, hidden_tensor): | |
| combined = torch.cat((input_tensor, hidden_tensor), 1) | |
| hidden = self.i2h(combined) | |
| output = self.i2o(combined) | |
| output = self.softmax(output) | |
| return output, hidden | |
| def init_hidden(self): | |
| return torch.zeros(1, self.hidden_size) |