-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from alexmul1114/lossfunctions
Add compatibility with LossFunctions.jl, test with least squares
- Loading branch information
Showing
6 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module LossFunctionsExt | ||
|
||
using GCPDecompositions, LossFunctions | ||
|
||
""" | ||
gcp(X::Array, r, loss::LossFunctions.SupervisedLoss, lower]) -> CPD | ||
Compute an approximate rank-`r` CP decomposition of the tensor `X` | ||
with respect to the loss function `loss` and return a `CPD` object. | ||
# Inputs | ||
+ `X` : multi-dimensional tensor/array to approximate/decompose | ||
+ `r` : number of components for the CPD | ||
+ `loss` : loss function from LossFunctions.jl | ||
+ `lower` : lower bound for factor matrix entries, `default = -Inf` | ||
""" | ||
GCPDecompositions.gcp(X::Array, r, loss::LossFunctions.SupervisedLoss, lower=-Inf) = | ||
GCPDecompositions._gcp(X, r, (x, m) -> loss(m, x), (x, m) -> LossFunctions.deriv(loss, m, x), lower, (;)) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
[deps] | ||
LossFunctions = "30fc2ffe-d236-52d8-8643-a9d8f7c094a7" | ||
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" | ||
|
||
[compat] | ||
LossFunctions = "0.11.1" | ||
OffsetArrays = "1.12.7" | ||
TestItemRunner = "0.2.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters