Skip to content

Commit

Permalink
remove name from at-compact
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Oct 13, 2023
1 parent 753127d commit d19d235
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function Flux._big_show(io::IO, obj::CompactLayer, indent::Int=0, name=nothing)
setup_strings = obj.setup_strings
layer, input, block = obj.strings
pre, post = ("(", ")")
println(io, " "^indent, isnothing(name) ? "" : "$name = ", layer, pre)
println(io, " "^indent, "@compact", pre)
for k in keys(obj.variables)
v = obj.variables[k]
if Flux._show_leaflike(v)
Expand Down
22 changes: 22 additions & 0 deletions test/compact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,28 @@ end
@test similar_strings(get_model_string(model2), expected_string)
end

#= # This test is broken:
julia> model1 = @compact(w1=Dense(32=>32, relu), w2=Dense(32=>32, relu)) do x
w2(w1(x));
julia> model2 = @compact(w1=model1, w2=Dense(32=>32, relu)) do x
w2(w1(x))
end
@compact(
@compact(
w1 = Dense(32 => 32, relu), # 1_056 parameters
w2 = Dense(32 => 32, relu), # 1_056 parameters
) do x
w2(w1(x))
end,
w2 = Dense(32 => 32, relu), # 1_056 parameters
) do x
w2(w1(x))
end # Total: 6 arrays, 3_168 parameters, 13.239 KiB.
=#

@testset "Array parameters" begin
model = @compact(x=randn(32), w=Dense(32=>32)) do s
w(x .* s)
Expand Down

0 comments on commit d19d235

Please sign in to comment.