LuminAIGeoLocation / models /networks /classification.py
natankatz's picture
Upload 7 files
0e057e7 verified
raw
history blame contribute delete
468 Bytes
import torch
import torch.nn as nn
class ClassificationHead(nn.Module):
"""Classification head for the network."""
def __init__(self, id_to_gps):
super().__init__()
self.id_to_gps = id_to_gps
def forward(self, x):
"""Forward pass of the network.
x : Union[torch.Tensor, dict] with the output of the backbone.
"""
gps = self.id_to_gps(x.argmax(dim=-1))
return {"label": x, **gps}