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 function works weird with NaN input #18

Open
T-H-ash opened this issue Nov 23, 2023 · 1 comment
Open

ReLU function works weird with NaN input #18

T-H-ash opened this issue Nov 23, 2023 · 1 comment

Comments

@T-H-ash
Copy link
Contributor

T-H-ash commented Nov 23, 2023

Hi,

It seems F.relu(NaN) returns 0, where NaN is expected. Here's a code sample:

console.log(`debug-cpu: ${(await (await F.relu(new K.nn.Variable(T.fromArray([NaN])))).data.to('cpu')).toArray()}`);
console.log(`debug-webgl: ${(await (await F.relu(new K.nn.Variable(await T.fromArray([NaN]).to('webgl')))).data.to('cpu')).toArray()}`);

And I got:

debug-cpu: 0
debug-webgl: 0

It seems the grad also returns 0 for NaN input (I did't confirm it well), where NaN is expected.

@milhidaka
Copy link
Member

https://stackoverflow.com/questions/37532640/making-a-nan-on-purpose-in-webgl
Whether or not NaN is implemented depends on the model, and it is difficult to handle well.

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

2 participants