File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def __init__(
2424 raise ValueError (f"`prob_distr` shape must be (D,), got { prob_distr .shape } ." )
2525 if prob_distr .dtype != torch .float32 :
2626 raise ValueError (f"`prob_distr` dtype must be torch.float32, got { prob_distr .dtype } ." )
27- if not torch .allclose (torch .sum (prob_distr ), torch .ones_like ( prob_distr )):
27+ if not torch .allclose (torch .sum (prob_distr ), torch .ones ( 1 , dtype = torch . float32 )):
2828 raise ValueError (f"`torch.sum(prob_distr)` must be 1., got { torch .sum (prob_distr )} ." )
2929
3030 self .prob_distr = prob_distr
@@ -35,7 +35,7 @@ def D(self):
3535
3636 def sample (
3737 self ,
38- num_samples : int
38+ num_samples : int ,
3939 ):
4040 N = num_samples
4141
@@ -74,3 +74,7 @@ def log_prob(
7474 log_prob = torch .log (self .prob_distr [l0_norm - 1 ])
7575 log_prob [l0_norm == 0 ] = - torch .inf
7676 return log_prob
77+
78+ # TODO: Add L0ExpPrior, where the number of active units is distributed exponentially.
79+
80+ # TODO: Add L0IidPrior, where the magnitude of an active unit is distributed according to an i.i.d. Prior.
You can’t perform that action at this time.
0 commit comments