Thanks, that was helpful, for anyone interested here how my macro looks like:
macro act(body: untyped): untyped =
result = nnkObjConstr.newTree(ident"ActivationFunction")
let flType = ident"NeuralFloat"
expectLen(body, 2)
for fn in body:
expectKind(fn, nnkCall)
let fnParam = fn[1]
let fnName = fn[0]
let fnBody = fn[2]
let fnType = [flType, newIdentDefs(fnParam, flType)]
let p = newProc(newEmptyNode(), fnType, fnBody, nnkLambda)
let field = nnkExprColonExpr.newTree(fnName, p)
result.add field
let sigmoid* = act:
fn(x): 1 / (1 + exp(-x))
deriv(fx): fx * (1 - fx)
Run
- Problem with export marker and macros b3liever
- Re: Problem with export marker and macros Stefan_Salewski
- Re: Problem with export marker and macros b3liever
- Re: Problem with export marker and macros Araq
- Re: Problem with export marker and macros b3liever
- Re: Problem with export marker and m... mratsim
- Re: Problem with export marker a... Araq
- Re: Problem with export mark... b3liever
- Re: Problem with export mark... bluenote
