From afe5f36c26541596b6ab54dd3fed6e12005f876a Mon Sep 17 00:00:00 2001 From: Mike J Innes Date: Mon, 22 Aug 2016 14:49:12 +0100 Subject: [PATCH] provide raw graph for models --- src/compiler/code.jl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/compiler/code.jl b/src/compiler/code.jl index e44e6563..3bd8250d 100644 --- a/src/compiler/code.jl +++ b/src/compiler/code.jl @@ -7,6 +7,19 @@ function process_func(ex, params) return args, body end +immutable Parameter + name +end + +function makegraph(graph, args) + @assert length(args) == 1 + mapconst(graph) do x + x == args[1] ? Parameter(1) : + @capture(x, self.p_) ? Parameter(p) : + x + end +end + function build_type(T, params) quote type $T @@ -59,6 +72,7 @@ function process_type(ex) back!(self::$T, Δ, $(args...)) = $(syntax(build_backward(body, args[1], params))) $(build_update(T, params)) end |> longdef + graph(::$T) = $(Flow.constructor(makegraph(body, args))) end # process_type(:(type Sigmoid