Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SymCPD type #70

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

alexmul1114
Copy link
Contributor

@alexmul1114 alexmul1114 commented Oct 2, 2024

Adding Symmetric CPD (SymCPD) type to support symmetric generalized CP decompositions in the future.

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

Attention: Patch coverage is 65.90909% with 60 lines in your changes missing coverage. Please review.

Project coverage is 89.11%. Comparing base (4900abe) to head (4b1f410).

Files with missing lines Patch % Lines
src/gcp-algorithms/lbfgsb.jl 0.00% 27 Missing ⚠️
src/gcp-losses.jl 0.00% 19 Missing ⚠️
src/GCPDecompositions.jl 0.00% 14 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (4900abe) and HEAD (4b1f410). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (4900abe) HEAD (4b1f410)
9 8
Additional details and impacted files
@@             Coverage Diff              @@
##            master      #70       +/-   ##
============================================
- Coverage   100.00%   89.11%   -10.89%     
============================================
  Files           13       13               
  Lines          378      551      +173     
============================================
+ Hits           378      491      +113     
- Misses           0       60       +60     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexmul1114
Copy link
Contributor Author

Added struct definition and constructor, as well as ncomps, ndims, size, and getindex functions for the SymCPD type. The way I have it set up currently is with $\lambda$ the same as in CPD, $U$ a k-tuple (instead of n-tuple as in CPD), where k is the number of groups of symmetric indices, and $S$ is a n-tuple of ints mapping indices to their group of symmetric indices.

@alexmul1114
Copy link
Contributor Author

Current implementation works sometimes but gets a message from LBFGSB about the line search failing sometimes. Need to check the implementation of the gradients.

julia> using GCPDecompositions: symgcp

julia> using GCPDecompositions: GCPAlgorithms.LBFGSB

julia> U1 = randn(50, 5);

julia> U2 = randn(100,5);

julia> X = zeros(50,100,50);

julia> for i1 in axes(U1, 1), i2 in axes(U2, 1), i3 in axes(U1, 1)
       X[i1,i2,i3] = sum(U1[i1,:].*U2[i2,:].*U1[i3,:])
       end

julia> r=5;

julia> S=(1,2,1);

julia> symgcp(X,r,S,algorithm=LBFGSB(iprint=0))
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =          750     M =           10
 This problem is unconstrained.

           * * *

Tit   = total number of iterations
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
  750    118    214      2     0     0   1.641D-03   5.044D-09

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH

 Total User time 4.016E+00 seconds.

GCPDecompositions.SymCPD{Float64, 3, 2, Vector{Float64}, Matrix{Float64}}([1.0, 1.0, 1.0, 1.0, 1.0], ([-0.11918929749329864 -1.2724469007624526 … -0.870107400330269 0.04966934885230875; -1.2991765380062754 -0.37177018362825986 … 0.5150619404504531 0.15462793146561693; … ; -0.6843013982199081 0.5827294596219785 … 0.47958196246631474 1.9701944770269133; 1.3196244341593173 0.032043865029284635 … -0.7615196194105708 0.11409868794415903], [-0.8120270258170258 -2.4931121824474904 … -0.7798001841923826 2.930681591824272; -1.3169065074544186 -0.21828985220189268 … -3.9932367288487898 1.8689807048764457; … ; 1.0646765213905314 -1.882228373392413 … 2.9068016565247605 0.6349502467851968; -0.1921145188068539 1.6504620292246774 … -0.9600423953104262 2.2952375803193386]), (1, 2, 1))

julia> symgcp(X,r,S,algorithm=LBFGSB(iprint=0))
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =          750     M =           10
 This problem is unconstrained.

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
  750     10     37      1     0     0   6.997D+03   1.778D+06

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH

 Warning:  more than 10 function and gradient
   evaluations in the last line search.  Termination
   may possibly be caused by a bad search direction.

 Total User time 2.500E-01 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant