diff options
Diffstat (limited to 'nerv/matrix/generic/cumatrix.c')
-rw-r--r-- | nerv/matrix/generic/cumatrix.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/nerv/matrix/generic/cumatrix.c b/nerv/matrix/generic/cumatrix.c index be3d627..df858e6 100644 --- a/nerv/matrix/generic/cumatrix.c +++ b/nerv/matrix/generic/cumatrix.c @@ -62,6 +62,45 @@ static int nerv_matrix_(lua_sigmoid_grad)(lua_State *L) { return 0; } +static int nerv_matrix_(lua_thres_mask)(lua_State *L) { + Status status; + Matrix *a = luaT_checkudata(L, 1, nerv_matrix_(tname)); + Matrix *b = luaT_checkudata(L, 2, nerv_matrix_(tname)); + MATRIX_ELEM thres = luaL_checknumber(L, 3); + MATRIX_ELEM low = luaL_checknumber(L, 4); + MATRIX_ELEM high = luaL_checknumber(L, 5); + nerv_matrix_(thres_mask)(a, b, thres, low, high, &status); + NERV_LUA_CHECK_STATUS(L, status); + return 0; +} + +static int nerv_matrix_(lua_rand_uniform)(lua_State *L) { + Status status; + Matrix *a = luaT_checkudata(L, 1, nerv_matrix_(tname)); + nerv_matrix_(rand_uniform)(a, &status); + NERV_LUA_CHECK_STATUS(L, status); + return 0; +} + +static int nerv_matrix_(lua_tanh)(lua_State *L) { + Status status; + Matrix *a = luaT_checkudata(L, 1, nerv_matrix_(tname)); + Matrix *b = luaT_checkudata(L, 2, nerv_matrix_(tname)); + nerv_matrix_(tanh)(a, b, &status); + NERV_LUA_CHECK_STATUS(L, status); + return 0; +} + +static int nerv_matrix_(lua_tanh_grad)(lua_State *L) { + Status status; + 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_(tanh_grad)(nerr, err, output, &status); + NERV_LUA_CHECK_STATUS(L, status); + return 0; +} + static int nerv_matrix_(lua_softmax)(lua_State *L) { Status status; Matrix *a = luaT_checkudata(L, 2, nerv_matrix_(tname)); @@ -328,9 +367,13 @@ static const luaL_Reg nerv_matrix_(extra_methods)[] = { {"fill", nerv_matrix_(lua_fill)}, {"sigmoid", nerv_matrix_(lua_sigmoid)}, {"sigmoid_grad", nerv_matrix_(lua_sigmoid_grad)}, + {"tanh", nerv_matrix_(lua_tanh)}, + {"tanh_grad", nerv_matrix_(lua_tanh_grad)}, + {"rand_uniform", nerv_matrix_(lua_rand_uniform)}, {"softmax", nerv_matrix_(lua_softmax)}, {"mul_elem", nerv_matrix_(lua_mul_elem)}, {"log_elem", nerv_matrix_(lua_log_elem)}, + {"thres_mask", nerv_matrix_(lua_thres_mask)}, {"copy_rows_fromh_by_idx", nerv_matrix_(lua_copy_rows_fromh_by_idx)}, {"copy_rows_fromd_by_idx", nerv_matrix_(lua_copy_rows_fromd_by_idx)}, {"expand_frm", nerv_matrix_(lua_expand_frm)}, |