|
379 | 379 | grad3 = An*slicewise_dot(CM, CM; dims=n) - slicewise_dot(Y, CM; dims=n) |
380 | 380 |
|
381 | 381 | # 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 |
385 | 385 | end |
386 | 386 | end |
387 | 387 |
|
@@ -643,20 +643,50 @@ end |
643 | 643 | tolerance=.01, |
644 | 644 | maxiter=1000, |
645 | 645 | rank=R, |
| 646 | + model=Tucker1, |
646 | 647 | converged=RelativeError, |
647 | | - constraints=[l1scale_cols! ∘ nonnegative!, nonnegative!], |
| 648 | + constraints=[simplex_rows!, simplex_cols!], #[l1scale_cols! ∘ nonnegative!, nonnegative!], |
648 | 649 | constrain_init=true, |
649 | 650 | constrain_output=true, |
650 | 651 | momentum=true, |
651 | | - final_constraints = l1scale_cols!, |
| 652 | + #final_constraints = l1scale_cols!, |
652 | 653 | stats=[ |
653 | 654 | Iteration, ObjectiveValue, GradientNNCone, RelativeError, FactorNorms, EuclideanLipschitz |
654 | 655 | ], |
655 | 656 | ) |
656 | 657 |
|
657 | | - decomposition_randn, stats, kwargs = fact(Y; model=CPDecomposition, options...); |
| 658 | + decomposition, stats, kwargs = fact(Y; options...); |
658 | 659 |
|
659 | 660 | @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 |
660 | 690 | end |
661 | 691 |
|
662 | 692 | @testset "TuckerFactorization" begin |
|
0 commit comments