forked from SciML/FluxNeuralOperators.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #78 from SciML/refactor
Refactor
- Loading branch information
Showing
25 changed files
with
146 additions
and
153 deletions.
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
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
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,4 +1,5 @@ | ||
using Burgers | ||
using FluxTraining | ||
using Test | ||
|
||
@testset "Burgers" begin | ||
|
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,4 +1,5 @@ | ||
using DoublePendulum | ||
using FluxTraining | ||
using Test | ||
|
||
@testset "DoublePendulum" begin | ||
|
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
File renamed without changes.
File renamed without changes.
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,3 +1,5 @@ | ||
export NOMAD | ||
|
||
struct NOMAD{T1, T2} | ||
approximator_net::T1 | ||
decoder_net::T2 | ||
|
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,50 @@ | ||
export GraphKernel | ||
|
||
""" | ||
GraphKernel(κ, ch, σ=identity) | ||
Graph kernel layer. | ||
## Arguments | ||
* `κ`: A neural network layer for approximation, e.g. a `Dense` layer or a MLP. | ||
* `ch`: Channel size for linear transform, e.g. `32`. | ||
* `σ`: Activation function. | ||
## Keyword Arguments | ||
* `init`: Initial function to initialize parameters. | ||
""" | ||
struct GraphKernel{A, B, F} <: MessagePassing | ||
linear::A | ||
κ::B | ||
σ::F | ||
end | ||
|
||
function GraphKernel(κ, ch::Int, σ = identity; init = Flux.glorot_uniform) | ||
W = init(ch, ch) | ||
return GraphKernel(W, κ, σ) | ||
end | ||
|
||
Flux.@functor GraphKernel | ||
|
||
function GeometricFlux.message(l::GraphKernel, x_i::AbstractArray, x_j::AbstractArray, e_ij) | ||
return l.κ(vcat(x_i, x_j)) | ||
end | ||
|
||
function GeometricFlux.update(l::GraphKernel, m::AbstractArray, x::AbstractArray) | ||
return l.σ.(GeometricFlux._matmul(l.linear, x) + m) | ||
end | ||
|
||
function (l::GraphKernel)(el::NamedTuple, X::AbstractArray) | ||
GraphSignals.check_num_nodes(el.N, X) | ||
_, V, _ = GeometricFlux.propagate(l, el, nothing, X, nothing, mean, nothing, nothing) | ||
return V | ||
end | ||
|
||
function Base.show(io::IO, l::GraphKernel) | ||
channel, _ = size(l.linear) | ||
print(io, "GraphKernel(", l.κ, ", channel=", channel) | ||
l.σ == identity || print(io, ", ", l.σ) | ||
print(io, ")") | ||
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
Oops, something went wrong.