-
-
Notifications
You must be signed in to change notification settings - Fork 617
Closed
Description
Semi-related to #2043 😄. Custom model structs use
@functor MyModelto define Functors.children etc. It would be nice if there was also
@define_layer_show MyModelto generate a method for Base.show, like
using Flux
function Base.show(io::IO, m::MIME"text/plain", x::MyModel)
if get(io, :typeinfo, nothing) === nothing # e.g. top level in REPL
Flux._big_show(io, x)
elseif !get(io, :compact, false) # e.g. printed inside a Vector, but not a Matrix
Flux._layer_show(io, x)
else
show(io, x)
end
end
endAlternatives:
- I guess this could also be built into
@functorbut I suspect it might be better to keep it separate/ opt-in so you can define your own show method if you want. Also, adding it to@functorwould also presumably be breaking since folks may have custom show methods already and that would generate method overwrite warnings and possibly break precompilation. - This could be done with an abstact type, but I think it's nice if folks are free to have their model partipicate in their own type hierarchy. But an abstract type seems OK too.
Metadata
Metadata
Assignees
Labels
No labels