| 25 | |
| 26 | class Siren(nn.Module): |
| 27 | def __init__(self, dim_in, dim_out, w0 = 1., c = 6., is_first = False, use_bias = True, activation = None, dropout = False): |
| 28 | super().__init__() |
| 29 | self.dim_in = dim_in |
| 30 | self.is_first = is_first |
| 31 | self.dim_out = dim_out |
| 32 | self.dropout = dropout |
| 33 | |
| 34 | weight = torch.zeros(dim_out, dim_in) |
| 35 | bias = torch.zeros(dim_out) if use_bias else None |
| 36 | self.init_(weight, bias, c = c, w0 = w0) |
| 37 | |
| 38 | self.weight = nn.Parameter(weight) |
| 39 | self.bias = nn.Parameter(bias) if use_bias else None |
| 40 | self.activation = Sine(w0) if activation is None else activation |
| 41 | |
| 42 | def init_(self, weight, bias, c, w0): |
| 43 | dim = self.dim_in |