provide raw graph for models

This commit is contained in:
Mike J Innes 2016-08-22 14:49:12 +01:00
parent 4667c55a8a
commit afe5f36c26
1 changed files with 14 additions and 0 deletions

View File

@ -7,6 +7,19 @@ function process_func(ex, params)
return args, body return args, body
end 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) function build_type(T, params)
quote quote
type $T type $T
@ -59,6 +72,7 @@ function process_type(ex)
back!(self::$T, Δ, $(args...)) = $(syntax(build_backward(body, args[1], params))) back!(self::$T, Δ, $(args...)) = $(syntax(build_backward(body, args[1], params)))
$(build_update(T, params)) $(build_update(T, params))
end |> longdef end |> longdef
graph(::$T) = $(Flow.constructor(makegraph(body, args)))
end end
# process_type(:(type Sigmoid # process_type(:(type Sigmoid