model -> net
This commit is contained in:
parent
066ecafd71
commit
b115d8ce3f
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import Flow: mapconst, cse
|
import Flow: mapconst, cse
|
||||||
|
|
||||||
export @model
|
export @net
|
||||||
|
|
||||||
function process_func(ex, params = [])
|
function process_func(ex, params = [])
|
||||||
@capture(shortdef(ex), (args__,) -> body_)
|
@capture(shortdef(ex), (args__,) -> body_)
|
||||||
@ -85,7 +85,7 @@ function process_anon(ex)
|
|||||||
:(Flux.Capacitor($(Flow.constructor(makegraph(body, args))))) |> esc
|
:(Flux.Capacitor($(Flow.constructor(makegraph(body, args))))) |> esc
|
||||||
end
|
end
|
||||||
|
|
||||||
macro model(ex)
|
macro net(ex)
|
||||||
isexpr(ex, :type) ? process_type(ex) :
|
isexpr(ex, :type) ? process_type(ex) :
|
||||||
isexpr(ex, :->, :function) ? process_anon(ex) :
|
isexpr(ex, :->, :function) ? process_anon(ex) :
|
||||||
error("Unsupported model expression $ex")
|
error("Unsupported model expression $ex")
|
||||||
|
@ -59,7 +59,7 @@ end
|
|||||||
#
|
#
|
||||||
# break!(atomise(r)) |> syntax |> prettify |> display
|
# break!(atomise(r)) |> syntax |> prettify |> display
|
||||||
|
|
||||||
@model type Recurrent
|
@net type Recurrent
|
||||||
Wx; Wh; B
|
Wx; Wh; B
|
||||||
hidden
|
hidden
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ export Dense
|
|||||||
|
|
||||||
# TODO: type hints for parameters
|
# TODO: type hints for parameters
|
||||||
|
|
||||||
@model type Dense
|
@net type Dense
|
||||||
W
|
W
|
||||||
b
|
b
|
||||||
x -> x*W + b
|
x -> x*W + b
|
||||||
@ -14,7 +14,7 @@ Dense(in::Integer, out::Integer; init = initn) =
|
|||||||
Base.show(io::IO, d::Dense) =
|
Base.show(io::IO, d::Dense) =
|
||||||
print(io, "Dense($(size(d.W.x,1)),$(size(d.W.x,2)))")
|
print(io, "Dense($(size(d.W.x,1)),$(size(d.W.x,2)))")
|
||||||
|
|
||||||
@model type Sigmoid
|
@net type Sigmoid
|
||||||
layer::Model
|
layer::Model
|
||||||
x -> σ(layer(x))
|
x -> σ(layer(x))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user