show methods

This commit is contained in:
Mike J Innes 2017-06-19 16:49:29 -07:00
parent 0a6b6e1d6f
commit ea5d43ed77
3 changed files with 16 additions and 0 deletions

View File

@ -97,6 +97,14 @@ end
mxnet(model, ctx = :cpu) = Model(model, toctx(ctx)) mxnet(model, ctx = :cpu) = Model(model, toctx(ctx))
function Base.show(io::IO, m::Model)
print(io, "MX.Model(")
show(io, m.model)
print(io, ", ")
show(io, m.ctx)
print(io, ")")
end
import Base: @get! import Base: @get!
# TODO: dims having its own type would be useful # TODO: dims having its own type would be useful

View File

@ -35,3 +35,5 @@ end
(m::Capacitor)(xs...) = interpmodel(m, xs...) (m::Capacitor)(xs...) = interpmodel(m, xs...)
graph(cap::Capacitor) = cap.graph graph(cap::Capacitor) = cap.graph
Base.show(io::IO, ::Capacitor) = print(io, "Capacitor(...)")

View File

@ -9,6 +9,12 @@ end
Stateful(model, ss) = Stateful(model, ss, state.(ss), state.(ss)) Stateful(model, ss) = Stateful(model, ss, state.(ss), state.(ss))
function Base.show(io::IO, m::Stateful)
print(io, "Stateful(")
show(io, m.model)
print(io, ")")
end
function (m::Stateful)(xs...) function (m::Stateful)(xs...)
m.istate = m.ostate m.istate = m.ostate
state, y = m.model((m.istate...,), xs...) state, y = m.model((m.istate...,), xs...)