Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【relu】激活函数的添加 #16

Open
sjhsbhqf opened this issue Oct 13, 2023 · 0 comments
Open

【relu】激活函数的添加 #16

sjhsbhqf opened this issue Oct 13, 2023 · 0 comments

Comments

@sjhsbhqf
Copy link

sjhsbhqf commented Oct 13, 2023

代码如下

Matrix *M_Relu(Matrix *_mat_origin) {/*
 * Absolute the value of elements in the Matrix (create).
 * 矩阵所有元素取Relu函数值,大于0不变,小于0赋值0*/
    Matrix *_mat = (Matrix *) malloc(sizeof(Matrix));
    _mat->row = _mat_origin->row;
    _mat->column = _mat_origin->column;
    int size = _mat->row * _mat->column;
    _mat->data = (MATRIX_TYPE *) malloc((size) * sizeof(MATRIX_TYPE));
    int i;
    for (i = 0; i < size; i++) {
        if(_mat_origin->data[i]<0)
        {
            _mat->data[i] = 0;
            continue;
        }
        _mat->data[i] = _mat_origin->data[i];
    }

    return _mat;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant