diff options
author | mfy43 <ted.sybil@gmail.com> | 2016-04-30 14:48:29 +0800 |
---|---|---|
committer | mfy43 <ted.sybil@gmail.com> | 2016-04-30 14:48:29 +0800 |
commit | 1aaffa6b9a56d4d580dea7bf3f1b7df1eec5da2f (patch) | |
tree | d705bbec5b701774a144810c5e60a73e346f9c39 /nerv/matrix/generic/matrix.c | |
parent | 6051c37a2c55365a5834d5b4c11d973e2e4e1ad4 (diff) | |
parent | 1f5568a9e1457dcf5aadd08749aef6194370b43f (diff) |
Merge branch 'master' into 'master'
add relu layer
See merge request !2
Diffstat (limited to 'nerv/matrix/generic/matrix.c')
-rw-r--r-- | nerv/matrix/generic/matrix.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/nerv/matrix/generic/matrix.c b/nerv/matrix/generic/matrix.c index 800408d..9f31b4b 100644 --- a/nerv/matrix/generic/matrix.c +++ b/nerv/matrix/generic/matrix.c @@ -430,4 +430,27 @@ static int nerv_matrix_(lua_tanh_grad)(lua_State *L) { return 0; } +static int nerv_matrix_(lua_relu)(lua_State *L) { + Status status; + MATRIX_CONTEXT *context; + MATRIX_GET_CONTEXT(L, 3); + Matrix *a = luaT_checkudata(L, 1, nerv_matrix_(tname)); + Matrix *b = luaT_checkudata(L, 2, nerv_matrix_(tname)); + nerv_matrix_(relu)(a, b, context, &status); + NERV_LUA_CHECK_STATUS(L, status); + return 0; +} + +static int nerv_matrix_(lua_relu_grad)(lua_State *L) { + Status status; + MATRIX_CONTEXT *context; + MATRIX_GET_CONTEXT(L, 4); + Matrix *nerr = luaT_checkudata(L, 1, nerv_matrix_(tname)); + Matrix *err = luaT_checkudata(L, 2, nerv_matrix_(tname)); + Matrix *output = luaT_checkudata(L, 3, nerv_matrix_(tname)); + nerv_matrix_(relu_grad)(nerr, err, output, context, &status); + NERV_LUA_CHECK_STATUS(L, status); + return 0; +} + #endif |