Skip to content

ReLU function works weird with NaN input #18

@T-H-ash

Description

@T-H-ash

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions