Skip to content

Instantly share code, notes, and snippets.

@rtkclouds
rtkclouds / idNorm_py.py
Last active November 23, 2023 04:00
The layer includes a custom hashing function. Hash functions are often used in neural networks for dimensionality
import torch
import torch.nn as nn
import math
class IdNorm(nn.Module):
def __init__(self, cluster_size=128):
super(IdNorm, self).__init__()
self.cluster_size = cluster_size
self.n = None # Será definido no método build
self.embs = nn.ModuleList()