deep_privacy2 / dp2 /layers /__init__.py
haakohu's picture
fix
44539fc
raw
history blame
502 Bytes
from typing import Dict
import torch
import tops
import torch.nn as nn
class Sequential(nn.Sequential):
def forward(self, x: Dict[str, torch.Tensor], **kwargs) -> Dict[str, torch.Tensor]:
for module in self:
x = module(x, **kwargs)
return x
class Module(nn.Module):
def __init__(self, *args, **kwargs):
super().__init__()
def extra_repr(self):
num_params = tops.num_parameters(self) / 10**6
return f"Num params: {num_params:.3f}M"