remove anon model compilation
This commit is contained in:
parent
467e829b64
commit
205e1215d6
|
@ -81,16 +81,8 @@ end
|
|||
|
||||
function process_anon(ex)
|
||||
args, body = process_func(ex)
|
||||
layers = Set{Symbol}()
|
||||
Flow.prefor(body) do v
|
||||
isexpr(value(v), Symbol) && push!(layers, value(v))
|
||||
end
|
||||
@assert length(args) == 1
|
||||
:(Flux.Capacitor(
|
||||
($(args...)) -> $(build_forward(body, args)),
|
||||
(Δ, $(args...)) -> $(build_backward(body, args[1])),
|
||||
η -> $(map(p -> :(update!($p, η)), layers)...),
|
||||
$(Flow.constructor(makegraph(body, args))))) |> esc
|
||||
:(Flux.Capacitor($(Flow.constructor(makegraph(body, args))))) |> esc
|
||||
end
|
||||
|
||||
macro model(ex)
|
||||
|
|
|
@ -39,17 +39,10 @@ accumulate!(x, Δ) = x
|
|||
export Capacitor
|
||||
|
||||
type Capacitor <: Model
|
||||
forward::Function
|
||||
backward::Function
|
||||
update::Function
|
||||
graph::IVertex{Any}
|
||||
end
|
||||
|
||||
(cap::Capacitor)(args...) = cap.forward(args...)
|
||||
|
||||
back!(cap::Capacitor, args...) = cap.backward(args...)
|
||||
|
||||
update!(cap::Capacitor, η) = cap.update(η)
|
||||
# TODO: Julia implementation that interprets the graph
|
||||
|
||||
graph(cap::Capacitor) = cap.graph
|
||||
|
||||
|
|
Loading…
Reference in New Issue