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