Skip to content

Commit

Permalink
Merge pull request #178 from avik-pal/ap/display
Browse files Browse the repository at this point in the history
Fix some displays
  • Loading branch information
avik-pal authored Oct 22, 2022
2 parents c0eced3 + e6c3239 commit 757fe76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Lux"
uuid = "b2108857-7c20-44ae-9111-449ecde12c47"
authors = ["Avik Pal <[email protected]> and contributors"]
version = "0.4.29"
version = "0.4.30"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
25 changes: 7 additions & 18 deletions src/layers/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ function _big_show(io::IO, obj, indent::Int=0, name=nothing)
for k in Base.keys(obj)
_big_show(io, obj.layers[k], indent + 4, k)
end
elseif children isa NamedTuple
for (k, c) in pairs(children)
_big_show(io, c, indent + 4, k)
end
else
if children isa NamedTuple
for (k, c) in pairs(children)
_big_show(io, c, indent + 4, k)
end
else
for c in children
_big_show(io, c, indent + 4)
end
for c in children
_big_show(io, c, indent + 4)
end
end
if indent == 0 # i.e. this is the outermost container
Expand All @@ -75,6 +73,7 @@ end
_get_children(s::SkipConnection) = (s.layers, s.connection)
_get_children(s::WeightNorm) = (s.layer,)
_get_children(::Any) = ()
_get_children(nt::NamedTuple) = nt

function Base.show(io::IO, ::MIME"text/plain", x::AbstractExplicitLayer)
if !get(io, :compact, false)
Expand Down Expand Up @@ -122,16 +121,6 @@ function underscorise(n::Integer)
return join(reverse(join.(reverse.(Iterators.partition(digits(n), 3)))), '_')
end

function _nan_show(io::IO, x)
if !isempty(x) && _all(iszero, x)
printstyled(io, " (all zero)"; color=:cyan)
elseif _any(isnan, x)
printstyled(io, " (some NaN)"; color=:red)
elseif _any(isinf, x)
printstyled(io, " (some Inf)"; color=:red)
end
end

_any(f, xs::AbstractArray{<:Number}) = any(f, xs)
_any(f, xs) = any(x -> _any(f, x), xs)
_any(f, x::Number) = f(x)
Expand Down

2 comments on commit 757fe76

@avik-pal
Copy link
Member 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/70798

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 v0.4.30 -m "<description of version>" 757fe7636f85f563412f7ccc83fa076dae055436
git push origin v0.4.30

Please sign in to comment.