UFR-Fing / src /models /aggregator.py
anbinh39's picture
Add files using upload-large-folder tool
dadf189 verified
Raw
History Blame Contribute Delete
496 Bytes
from __future__ import annotations
import torch
import torch.nn as nn
class ScoreAggregator(nn.Module):
"""Aggregate concept vector into scalar score in [0, 100]."""
def __init__(self, k: int = 6):
super().__init__()
self.mlp = nn.Sequential(
nn.Linear(k, 32),
nn.GELU(),
nn.Linear(32, 1),
nn.Sigmoid(),
)
def forward(self, concepts: torch.Tensor) -> torch.Tensor:
return self.mlp(concepts) * 100.0