Skip to content

Commit 7ce2eaa

Browse files
committed
adapt hals code
1 parent 39c7174 commit 7ce2eaa

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

tensorly/decomposition/_nn_cp.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ def non_negative_parafac_hals(
387387

388388
# initialisation - declare local variables
389389
rec_errors = []
390-
regs_loss = []
391390

392391
# Iteration
393392
for iteration in range(n_iter_max):
@@ -442,16 +441,6 @@ def non_negative_parafac_hals(
442441

443442
if tol or verbose or (callback is not None):
444443
unnorml_rec_error = tl.sqrt(norm_tensor + factors_norm**2 - 2 * iprod)
445-
#regs_loss.append(
446-
#sum(
447-
#[
448-
#sparsity_coefficients[i] * tl.sum(tl.abs(factors[i]))
449-
#+ ridge_coefficients[i] * tl.norm(factors[i]) ** 2
450-
#for i in range(n_modes)
451-
#]
452-
#)
453-
#)
454-
#rec_errors.append((rec_error + regs_loss[-1]) / norm_tensor) # loss !
455444
rec_errors.append(unnorml_rec_error)
456445

457446
if callback is not None:
@@ -468,7 +457,7 @@ def non_negative_parafac_hals(
468457
if verbose and not (iteration % print_it):
469458
if iteration >= 1:
470459
print(
471-
f"iteration {iteration}, norm. loss: {rec_errors[-1]}, rec error: {rec_error}, regs: {regs_loss[-1]}, decrease = {rec_error_decrease}"
460+
f"iteration {iteration}, rec error: {rec_errors[-1]}, decrease = {rec_error_decrease}"
472461
)
473462
else:
474463
print(f"first iteration, initial loss={rec_errors[-1]}.")
@@ -483,7 +472,7 @@ def non_negative_parafac_hals(
483472
# final print
484473
if verbose:
485474
print(
486-
f"iter={iteration}, loss={rec_errors[-1]}, variation={rec_errors[-2] - rec_errors[-1]}, regs={tl.sum(regs)}."
475+
f"iter={iteration}, rec error={rec_errors[-1]}, variation={rec_errors[-2] - rec_errors[-1]}."
487476
)
488477

489478
cp_tensor = CPTensor((weights, factors))

0 commit comments

Comments
 (0)