Skip to content

Commit

Permalink
Merge pull request #49 from DrChainsaw/flux0.10.4
Browse files Browse the repository at this point in the history
Flux0.10.4
  • Loading branch information
DrChainsaw authored May 12, 2020
2 parents c2127bc + 86d7917 commit 3092918
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "NaiveNASflux"
uuid = "85610aed-7d32-5e57-bb50-4c2e1c9e7997"
version = "1.1.2"
version = "1.2.0"

[deps]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Expand All @@ -14,7 +14,7 @@ Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
Flux = "=0.10.3"
Flux = "0.10.4"
JuMP = "0.19, 0.20, 0.21"
NaiveNASlib = "1"
Reexport = "0.2.0"
Expand Down
9 changes: 7 additions & 2 deletions src/NaiveNASflux.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module NaiveNASflux

using Reexport
@reexport using NaiveNASlib
@reexport using Flux
using NaiveNASlib
using Flux
import Flux.Zygote: hook
using Statistics
using Setfield
Expand Down Expand Up @@ -37,4 +37,9 @@ include("weightinit.jl")
include("functor.jl")
include("zygote.jl")

# Reexporting before include("functor.jl") causes a warning about duplicate name (flatten) in NaiveNASlib and Flux when subtypes are called
# https://discourse.julialang.org/t/avoid-error-message-for-function-name-conflict/37176/10
@reexport using NaiveNASlib
@reexport using Flux

end # module
2 changes: 2 additions & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ layertype(l::MaxPool) = FluxNoParLayer()
layertype(l::MeanPool) = FluxNoParLayer()
layertype(l::Dropout) = FluxNoParLayer()
layertype(l::AlphaDropout) = FluxNoParLayer()
layertype(l::GlobalMaxPool) = FluxNoParLayer()
layertype(l::GlobalMeanPool) = FluxNoParLayer()

# Compositions? Might not have any common methods...
# MaxOut, Chain?
4 changes: 2 additions & 2 deletions src/zygote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ end

function output_loop!(memo, v)
vs = nograd() do
# flatten returns all input ancestors to v in topological order
# NaiveNASlib.flatten returns all input ancestors to v in topological order
# We also provide all vertices for which we have the output already in memo
# so we don't do unnecessary calculations.
flatten(v, collect(AbstractVertex, keys(memo)))[length(memo)+1:end]
NaiveNASlib.flatten(v, collect(AbstractVertex, keys(memo)))[length(memo)+1:end]
end

for vn in vs
Expand Down
10 changes: 10 additions & 0 deletions test/pruning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@
@test size(neuron_value(l)) == (2,)
end

@testset "Neuron value GlobalMeanPool act contrib" begin
l = ml(GlobalMeanPool(), ActivationContribution, insize=2)
@test ismissing(neuron_value(l))
tr(l, ones(Float32, 4,4,2,5))

@test ismissing(minΔninfactor(l))
@test ismissing(minΔnoutfactor(l))
@test size(neuron_value(l)) == (2,)
end

@testset "Elem add ActivationContribution" begin
ac(l) = ActivationContribution(l)
v = ac >> ml(Dense(2,3)) + ml(Dense(4,3))
Expand Down
6 changes: 3 additions & 3 deletions test/vertex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end

W2exp, b2exp = weights(dl2)[:, inds], bias(dl2)
W1exp, b1exp = weights(dl1)[inds, :], bias(dl1)[inds]
apply_mutation.(flatten(dense2))
apply_mutation.(NaiveNASlib.flatten(dense2))

@test size(CompGraph([inpt], [dense2])(collect(Float32, 1:nout(inpt)))) == (3,)

Expand All @@ -63,7 +63,7 @@ end
@test nin(bv) == [nout(cv)] == [4]

Δnin(bv, -1)
apply_mutation.(flatten(bv))
apply_mutation.(NaiveNASlib.flatten(bv))

@test nin(bv) == [nout(cv)] == [3]
end
Expand All @@ -76,7 +76,7 @@ end
@test nin(bv) == [nout(cv)] == [4]

Δnin(bv, -1)
apply_mutation.(flatten(bv))
apply_mutation.(NaiveNASlib.flatten(bv))

@test nin(bv) == [nout(cv)] == [3]
end
Expand Down

2 comments on commit 3092918

@DrChainsaw
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

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/14635

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:

git tag -a v1.2.0 -m "<description of version>" 3092918a979d0be4e776ec8741bb049ad11c2261
git push origin v1.2.0

Please sign in to comment.