-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Deeponet multi-output fix #11
Closed
+142
−50
Closed
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
55dc372
deeponet multi-output fix
ayushinav 36745f3
test bug fix
ayushinav acd35d1
format
ayushinav ec0644a
compat with additional layer
ayushinav a0e57d2
inference tests
ayushinav f238d80
explicit import test fix
ayushinav a99e89f
chore: set version to 1.0.0-DEV
avik-pal eabe384
chore: start migration to NeuralOperators.jl
avik-pal 3781405
refactor: remove the ext in favor of LuxDeviceUtils
avik-pal 1db83a6
fix: update doctests to not check printing
avik-pal 1926a26
ci: use updated CI scripts
avik-pal ddb1f75
test: lazy install cuda and amdgpu
avik-pal d2beb52
ci: create local preferences in CI script
avik-pal de70851
test: more explicit imports testing
avik-pal f7f1ee2
test: display layers
avik-pal c542639
Merge branch 'main' into fixes
ayushinav a8149e2
fixes
ayushinav 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
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,22 @@ | ||
# function Base.show(io::IO, model::conv) where {conv <: OperatorConv} | ||
# # print(io, model.name*"() # "*string(Lux.parameterlength(model))*" parameters") | ||
# print(io, model.name) | ||
# end | ||
|
||
# function Base.show(io::IO, ::MIME"text/plain", model::conv) where {conv <: OperatorConv} | ||
# show(io, model.name) | ||
# end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove these, printing was fixed upstream |
||
|
||
function Base.show(io::IO, model::Lux.CompactLuxLayer{:DeepONet}) | ||
_print_wrapper_model(io, "Branch net :\n", model.layers.branch) | ||
print(io, "\n \n") | ||
_print_wrapper_model(io, "Trunk net :\n", model.layers.trunk) | ||
if :additional in keys(model.layers) | ||
print(io, "\n \n") | ||
_print_wrapper_model(io, "Additional net :\n", model.layers.additional) | ||
end | ||
end | ||
ayushinav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
function Base.show(io::IO, ::MIME"text/plain", x::CompactLuxLayer{:DeepONet}) | ||
show(io, x) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,34 @@ | ||
# Temporarily capture certain calls like AMDGPU for ComplexFloats | ||
@inline __batched_mul(x, y) = x ⊠ y | ||
|
||
@inline function __project(b::AbstractArray{T1, 2}, t::AbstractArray{T2, 3}) where {T1, T2} | ||
# b : p x nb | ||
# t : p x N x nb | ||
b_ = reshape(b, size(b, 1), 1, size(b, 2)) # p x 1 x nb | ||
return dropdims(sum(b_ .* t; dims=1); dims=1) # N x nb | ||
end | ||
|
||
@inline function __project(b::AbstractArray{T1, 3}, t::AbstractArray{T2, 3}) where {T1, T2} | ||
# b : p x u x nb | ||
# t : p x N x nb | ||
if size(b, 2) == 1 || size(t, 2) == 1 | ||
return sum(b .* t; dims=1) # 1 x N x nb | ||
else | ||
return __batched_mul(batched_adjoint(t), b) # N x p x nb | ||
end | ||
end | ||
|
||
@inline function __project( | ||
b::AbstractArray{T1, N}, t::AbstractArray{T2, 3}) where {T1, T2, N} | ||
# b : p x u_size x nb | ||
# t : p x N x nb | ||
u_size = size(b)[2:(end - 1)] | ||
|
||
b_ = reshape(b, size(b, 1), 1, u_size..., size(b)[end]) | ||
# p x 1 x u_size x nb | ||
|
||
t_ = reshape(t, size(t)[1:2]..., ones(eltype(u_size), length(u_size))..., size(t)[end]) | ||
# p x N x (1,1,1...) x nb | ||
|
||
return dropdims(sum(b_ .* t_; dims=1); dims=1) # N x u_size x nb | ||
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
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.
input for additional layer should be size of inner embedding size
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.
So it not need
reduction/sum/dropdim
beforeadditional layer.
It should beadditional = Chain(Dense(16 => 4));
here. Otherwise It's created a bottleneck and we lose information here.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.
Should be fixed now. Using the
linear
layer asadditional
layer for the cases where we do not have theadditional
layer did not seem ideal to me because it would imply weighted sum, where the weights would be learnt during training, but since DeepONets by default take the dot product, aka non-weighted sum, which could be required by many users.