Skip to content

Commit ff1cf50

Browse files
committed
add CPDecomposition test using Tucker1
1 parent 5833a89 commit ff1cf50

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

test/runtests.jl

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@ end
379379
grad3 = An*slicewise_dot(CM, CM; dims=n) - slicewise_dot(Y, CM; dims=n)
380380

381381
# should all give the same answer
382-
@test all(grad1 . grad2)
383-
@test all(grad1 . grad3)
384-
@test all(grad2 . grad3)
382+
@test grad1 grad2
383+
@test grad1 grad3
384+
@test grad2 grad3
385385
end
386386
end
387387

@@ -643,20 +643,50 @@ end
643643
tolerance=.01,
644644
maxiter=1000,
645645
rank=R,
646+
model=Tucker1,
646647
converged=RelativeError,
647-
constraints=[l1scale_cols! nonnegative!, nonnegative!],
648+
constraints=[simplex_rows!, simplex_cols!], #[l1scale_cols! ∘ nonnegative!, nonnegative!],
648649
constrain_init=true,
649650
constrain_output=true,
650651
momentum=true,
651-
final_constraints = l1scale_cols!,
652+
#final_constraints = l1scale_cols!,
652653
stats=[
653654
Iteration, ObjectiveValue, GradientNNCone, RelativeError, FactorNorms, EuclideanLipschitz
654655
],
655656
)
656657

657-
decomposition_randn, stats, kwargs = fact(Y; model=CPDecomposition, options...);
658+
decomposition, stats, kwargs = fact(Y; options...);
658659

659660
@test stats[end, :Iteration] < 1000 # ensure we did not hit the maximum number of iterations
661+
N = 100
662+
R = 5
663+
D = 2
664+
665+
matrices = [abs_randn(N, R) for _ in 1:D]
666+
l1scale_cols!.(matrices)
667+
Ydecomp = CPDecomposition(Tuple(matrices))#abs_randn
668+
@assert all(check.(simplex_cols!, factors(Ydecomp)))
669+
Y = array(Ydecomp)
670+
671+
options = (
672+
tolerance=.01,
673+
maxiter=1000,
674+
rank=R,
675+
model=CPDecomposition,
676+
converged=RelativeError,
677+
constraints=[l1scale_cols! nonnegative!, simplex_cols!], #[l1scale_cols! ∘ nonnegative!, nonnegative!],
678+
constrain_init=false,
679+
constrain_output=true,
680+
momentum=true,
681+
#final_constraints = l1scale_cols!,
682+
stats=[
683+
Iteration, ObjectiveValue, GradientNNCone, RelativeError, FactorNorms, EuclideanLipschitz
684+
],
685+
)
686+
687+
decomposition, stats, kwargs = fact(Y; options...);
688+
689+
@test_broken stats[end, :Iteration] < 1000 # ensure we did not hit the maximum number of iterations
660690
end
661691

662692
@testset "TuckerFactorization" begin

0 commit comments

Comments
 (0)