Spaces:
Running
Running
File size: 592 Bytes
7dc128b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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 |