remove anon model compilation

This commit is contained in:
Mike J Innes 2016-09-06 16:23:39 +01:00
parent 467e829b64
commit 205e1215d6
2 changed files with 2 additions and 17 deletions

View File

@ -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)

View File

@ -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