Spaces:
Running
Running
File size: 497 Bytes
370b46c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import torch
import torch.nn as nn
class ProgrammingEmbedding(nn.Module):
"""
Maps sentence vectors into programming-related feature space.
"""
def __init__(self, input_dim: int = 128, hidden_dim: int = 128):
super().__init__()
self.network = nn.Sequential(
nn.Linear(input_dim, hidden_dim),
nn.ReLU(),
nn.LayerNorm(hidden_dim)
)
def forward(self, x: torch.Tensor) -> torch.Tensor:
return self.network(x) |