Skip to content

Conversation

@BruceDai
Copy link
Contributor

@BruceDai BruceDai commented Mar 9, 2023

@huningxin @fdwr PTAL, thanks.

*/
export function prelu(x, slope) {
const zero = new Tensor([1], [0]);
return add(max(zero, x), mul(slope, min(zero, x)));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting way of expressing it. I like that you can compose it from simpler operators. Also, this handles any broadcasting automatically for you because mul handles it.

'shape': [1, 2, 3],
'data': [
1, -0.1, 2,
-0.2, 3, -0.30000000000000004,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using 0.125 rather than 0.1 if you want exact answers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fdwr Thanks. I've updated tests, please have another look.

@huningxin huningxin merged commit 063c404 into webmachinelearning:main Mar 16, 2023
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

Successfully merging this pull request may close these issues.

3 participants