diff --git a/Project.toml b/Project.toml index a22eec0..f2f1de5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LegolasFlux" uuid = "eb5f792d-d1b1-4535-bae3-d5649ec7daa4" authors = ["Beacon Biosignals, Inc."] -version = "0.1.2" +version = "0.1.3" [deps] Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45" @@ -12,7 +12,7 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] Arrow = "1" Flux = "0.12" -Functors = "0.2.1" +Functors = "0.2.6" Legolas = "0.1, 0.2" Tables = "1" julia = "1.5" diff --git a/src/functors.jl b/src/functors.jl index 9b98504..a88b5eb 100644 --- a/src/functors.jl +++ b/src/functors.jl @@ -1,16 +1,3 @@ -# Modified version of `fcollect` to use an `IdSet` cache so that -# distinct arrays whose values happen to be duplicates are each kept. -# -function fcollect2(x; output=[], cache=IdSet(), exclude=_ -> false) - x in cache && return output - if !exclude(x) - push!(cache, x) - push!(output, x) - foreach(y -> fcollect2(y; cache=cache, output=output, exclude=exclude), Functors.children(x)) - end - return output -end - """ fetch_weights(m) -> Vector{Array} @@ -22,7 +9,7 @@ custom types. Note that this function does not copy the results, so that e.g. mutating `fetch_weights(m)[1]` modifies the model. """ -fetch_weights(m) = filter(is_numeric_array, fcollect2(m)) +fetch_weights(m) = filter(is_numeric_array, fcollect(m)) is_numeric_array(x) = false is_numeric_array(x::Array{<:Number}) = true is_numeric_array(x::Array) = all(x -> x isa Number || is_numeric_array(x), x)