sharpenb's picture
12f7cda603d2d60cc34959145e1ff2e58e8b044be3925bf8be4cd6b5e3d1a887
6cbacb6 verified
raw
history blame
No virus
292 Bytes
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor
class SharedEmbedding(nn.Embedding):
def forward(self, input: Tensor, unembed: bool=False) -> Tensor:
if unembed:
return F.linear(input, self.weight)
return super().forward(input)