-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MLUtils and Flux v0.13 compatibility (#155)
* MLUtils and Flux v0.13 compatibility * bimp version * cleanup * cleanup * import MLUtils * using numobs, getobs
- Loading branch information
1 parent
2801b51
commit c7d0afe
Showing
8 changed files
with
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +0,0 @@ | ||
## Deprecated in v0.2 | ||
|
||
function compute_message end | ||
function update_node end | ||
function update_edge end | ||
|
||
compute_message(l, xi, xj, e) = compute_message(l, xi, xj) | ||
update_node(l, x, m̄) = m̄ | ||
update_edge(l, e, m) = e | ||
|
||
function propagate(l::GNNLayer, g::GNNGraph, aggr, x, e=nothing) | ||
@warn """ | ||
Passing a GNNLayer to propagate is deprecated, | ||
you should pass the message function directly. | ||
The new signature is `propagate(f, g, aggr; [xi, xj, e])`. | ||
The functions `compute_message`, `update_node`, | ||
and `update_edge` have been deprecated as well. Please | ||
refer to the documentation. | ||
""" | ||
m = apply_edges((a...) -> compute_message(l, a...), g, x, x, e) | ||
m̄ = aggregate_neighbors(g, aggr, m) | ||
x = update_node(l, x, m̄) | ||
e = update_edge(l, e, m) | ||
return x, e | ||
end | ||
|
||
## Deprecated in v0.3 | ||
|
||
@deprecate copyxj(xi, xj, e) copy_xj(xi, xj, e) | ||
|
||
@deprecate CGConv(nin::Int, ein::Int, out::Int, args...; kws...) CGConv((nin, ein) => out, args...; kws...) | ||
|
||
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,34 +1,3 @@ | ||
@testset "deprecations" begin | ||
@testset "propagate" begin | ||
struct GCN{A<:AbstractMatrix, B, F} <: GNNLayer | ||
weight::A | ||
bias::B | ||
σ::F | ||
end | ||
|
||
Flux.@functor GCN # allow collecting params, gpu movement, etc... | ||
|
||
function GCN(ch::Pair{Int,Int}, σ=identity) | ||
in, out = ch | ||
W = Flux.glorot_uniform(out, in) | ||
b = zeros(Float32, out) | ||
GCN(W, b, σ) | ||
end | ||
|
||
GraphNeuralNetworks.compute_message(l::GCN, xi, xj, e) = xj | ||
|
||
function (l::GCN)(g::GNNGraph, x::AbstractMatrix{T}) where T | ||
x, _ = propagate(l, g, +, x) | ||
return l.σ.(l.weight * x .+ l.bias) | ||
end | ||
|
||
function new_forward(l, g, x) | ||
x = propagate(copy_xj, g, +, xj=x) | ||
return l.σ.(l.weight * x .+ l.bias) | ||
end | ||
|
||
g = GNNGraph(random_regular_graph(10, 4), ndata=randn(3, 10)) | ||
l = GCN(3 => 5, tanh) | ||
@test l(g, g.ndata.x) ≈ new_forward(l, g, g.ndata.x) | ||
end | ||
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
c7d0afe
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.
@JuliaRegistrator register
c7d0afe
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.
Registration pull request created: JuliaRegistries/General/58227
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: