Skip to content

Commit

Permalink
Set default hidden layer size of spectral neural network to max(log(n…
Browse files Browse the repository at this point in the history
…_dim), 4)
  • Loading branch information
davidnabergoj committed Dec 27, 2023
1 parent 3df7362 commit 43168a5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion normalizing_flows/bijections/finite/residual/iterative.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
from typing import Union, Tuple

import torch
Expand Down Expand Up @@ -52,7 +53,10 @@ def forward(self, x):


class SpectralNeuralNetwork(nn.Sequential):
def __init__(self, n_dim: int, n_hidden: int = 100, n_hidden_layers: int = 2, **kwargs):
def __init__(self, n_dim: int, n_hidden: int = None, n_hidden_layers: int = 2, **kwargs):
if n_hidden is None:
n_hidden = int(max(math.log(n_dim), 4))

layers = []
if n_hidden_layers == 0:
layers = [SpectralLinear(n_dim, n_dim, **kwargs)]
Expand Down

0 comments on commit 43168a5

Please sign in to comment.