Skip to content

Commit df1270f

Browse files
authored
Merge pull request #5 from lilab-bcb/develop
use normal init for iNMF by default
2 parents e7cf992 + d6660d3 commit df1270f

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

nmf/inmf_models/_inmf_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(
1818
):
1919
self._n_components = n_components
2020

21-
assert init in ['norm', 'uniform'], "Initialization method must be chosen from ['norm', 'uniform']!"
21+
assert init in ['normal', 'uniform'], "Initialization method must be chosen from ['normal', 'uniform']!"
2222
self._init_method = init
2323

2424
self._lambda = lam
@@ -44,7 +44,7 @@ def _initialize_W_H_V(self):
4444
self.H = []
4545
self.V = []
4646

47-
if self._init_method == 'norm':
47+
if self._init_method == 'normal':
4848
self.W = torch.zeros((self._n_components, self._n_features), dtype=self._tensor_dtype, device=self._device_type)
4949
for k in range(self._n_batches):
5050
avg = torch.sqrt(self.X[k].mean() / self._n_components)

nmf/nmf.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def run_nmf(
205205
def integrative_nmf(
206206
X: List[Union[np.array, torch.tensor]],
207207
n_components: int,
208-
init: Optional[str] = None,
208+
init: str = 'normal',
209209
algo: str = "halsvar",
210210
mode: str = "online",
211211
tol: float = 1e-4,
@@ -249,8 +249,8 @@ def integrative_nmf(
249249
The input list of non-negative matrices of shape (n_samples_i, n_features), one per batch. The n_samples_i is number of samples in batch i, and all batches must have the same number of features.
250250
n_components: ``int``
251251
Number of components achieved after iNMF.
252-
init: ``str``, optional, default: ``None``
253-
Method for initialization on H, W, and V matrices. Available options are: ``norm``, ``uniform``, meaning using random numbers generated from Normal or Uniform distribution.
252+
init: ``str``, optional, default: ``normal``
253+
Method for initialization on H, W, and V matrices. Available options are: ``normal`` or ``uniform``, meaning using random numbers generated from Normal or Uniform distribution.
254254
If ``None``, use ``norm`` for online mode, while ``uniform`` for batch mode, in order to achieve best performance.
255255
algo: ``str``, optional, default: ``halsvar``
256256
Choose from ``mu`` (Multiplicative Update), ``halsvar`` (Hierarchical Alternative Least Square variant, mimic bpp for better convergence) and ``bpp`` (alternative non-negative least squares with Block Principal Pivoting method).
@@ -321,9 +321,6 @@ def integrative_nmf(
321321
if mode not in {'batch', 'online'}:
322322
raise ValueError("Parameter mode must be a valid value from ['batch', 'online']!")
323323

324-
if init is None:
325-
init = 'norm' if mode == 'online' else 'uniform'
326-
327324
model_class = None
328325
kwargs = {'device_type': device_type, 'lam': lam, 'fp_precision': fp_precision}
329326

0 commit comments

Comments
 (0)