Skip to content

Commit

Permalink
Fix nan propagation in tf.relu (tensorflow#1001)
Browse files Browse the repository at this point in the history
BUG Default behavior changed with newest NVidia Drivers in Mac OS >=10.13.4 so we have to check for NaN explicitly.
  • Loading branch information
dsmilkov authored Apr 26, 2018
1 parent 24c78cc commit d3bf768
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/kernels/webgl/unaryop_gpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const CHECK_NAN_SNIPPET = `if (isNaN(x)) return x;`;

export const ABS = `return abs(x);`;

export const RELU = `return (x < 0.0) ? 0.0 : x;`;
export const RELU = CHECK_NAN_SNIPPET + `
return (x < 0.0) ? 0.0 : x;
`;

export const ELU = `return (x >= 0.0) ? x : (exp(x) - 1.0);`;

Expand Down

0 comments on commit d3bf768

Please sign in to comment.