Spaces:
Running
Running
| import torch | |
| import torch.nn as nn | |
| class ProgrammingEncoder(nn.Module): | |
| """ | |
| Encodes text embeddings into a programming-focused vector space. | |
| """ | |
| def __init__(self, input_dim: int = 128, hidden_dim: int = 128, output_dim: int = 128): | |
| super().__init__() | |
| self.fc1 = nn.Linear(input_dim, hidden_dim) | |
| self.activation = nn.ReLU() | |
| self.fc2 = nn.Linear(hidden_dim, output_dim) | |
| def forward(self, sentence_vec: torch.Tensor) -> torch.Tensor: | |
| x = self.fc1(sentence_vec) | |
| x = self.activation(x) | |
| x = self.fc2(x) | |
| return x |