-
Notifications
You must be signed in to change notification settings - Fork 1
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
Constant Linear Layer #18
Merged
Merged
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
01bb9e0
Initialise ConstLinearLayer
zhanglw0521 9ce22da
Merge branch 'Rnl_Basis' into Const_LinearLayer
zhanglw0521 0047583
keep it consistent to the Radial_Basis... branch
zhanglw0521 adf0519
Merge branch 'Rnl_Basis' into Const_LinearLayer
zhanglw0521 8c5ed6c
WIP - far from complete
zhanglw0521 9199843
Merge branch 'Rnl_Basis' into Const_LinearLayer
zhanglw0521 02e303d
partially works
zhanglw0521 8e7fcf0
Clean up
zhanglw0521 53a472d
Adapt Yangshuai's energy fitting code to the latest version
zhanglw0521 1b945d3
Merge branch 'Rnl_Basis' into Const_LinearLayer
zhanglw0521 4a7a06d
introduce rpe_basis & a linear dependence test
zhanglw0521 7252202
Fix the linear dependence issue
zhanglw0521 7dc53bc
Update Project.toml
zhanglw0521 92b2b3d
Typo fix
zhanglw0521 43d1a4f
Add the corresponding tests
zhanglw0521 ba40276
typo fix
zhanglw0521 0e3b9c8
Merge pull request #19 from ACEsuit/Linear_dependence_issue
zhanglw0521 a115a63
A simple energy test that checks the "completeness" of the basis for …
zhanglw0521 b363596
Resolve most of the issues in comments
zhanglw0521 ae937d1
Renaming W to op to avoid ambiguity of learnable weigh and constant m…
zhanglw0521 149447d
get rid of the "position" projectin
zhanglw0521 42ad3a9
clean up
zhanglw0521 8e63f32
Minor revision
zhanglw0521 bdffa55
faster linear transformation construction
zhanglw0521 7223e6c
turning C * X[pos] to LO * X with LO a combined LinearOperator
zhanglw0521 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,36 @@ | ||
import ChainRulesCore: rrule | ||
using LuxCore | ||
using LuxCore: AbstractExplicitLayer | ||
|
||
struct ConstLinearLayer <: AbstractExplicitLayer | ||
op | ||
end | ||
|
||
(l::ConstLinearLayer)(x::AbstractVector) = l.op * x[1:size(l.op,2)] | ||
cortner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
(l::ConstLinearLayer)(x::AbstractMatrix) = begin | ||
Tmp = l(x[1,:]) | ||
for i = 2:size(x,1) | ||
Tmp = [Tmp l(x[i,:])] | ||
end | ||
return Tmp' | ||
end | ||
|
||
(l::ConstLinearLayer)(x::AbstractArray,ps,st) = (l(x), st) | ||
|
||
# NOTE: the following rrule is kept because there is a issue with SparseArray | ||
function rrule(::typeof(LuxCore.apply), l::ConstLinearLayer, x::AbstractVector) | ||
zhanglw0521 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val = l(x) | ||
function pb(A) | ||
return NoTangent(), NoTangent(), l.op' * A[1], (op = A[1] * x',), NoTangent() | ||
end | ||
return val, pb | ||
end | ||
|
||
function rrule(::typeof(LuxCore.apply), l::ConstLinearLayer, x::AbstractArray,ps,st) | ||
val = l(x,ps,st) | ||
function pb(A) | ||
return NoTangent(), NoTangent(), l.op' * A[1], (op = A[1] * x',), NoTangent() | ||
end | ||
return val, pb | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this gives you a type instability. you still need to specify the type of the operator. Something like this: