tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.49k stars 1.93k forks source link

The operator tf.cosh return Infinity #8391

Open liliquan0118 opened 1 month ago

liliquan0118 commented 1 month ago

Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template

System information

Describe the current behavior Given the input [[[2010266160.7859912]]], the operator return Infinity

Output: image

Describe the expected behavior Not return Infinity

Standalone code to reproduce the issue Provide a reproducible test case that is the bare minimum necessary to generate the problem. If possible, please share a link to Colab/CodePen/any notebook.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>bug00</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.2.0/dist/tf.js"> </script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@4.2.0/dist/tf-backend-wasm.js"></script>
<script>
    function cosh(backend){
        tf.setBackend(backend);
        tf.ready().then(()=>{var input=[[[2010266160.7859912]]]
            const result = tf.cosh(input);
            console.log("the result of ", backend, "is:\n" );
            result.print();
        })
    }
    async function test() {
        await cosh("webgl");
        await cosh("cpu");
        await cosh("wasm");
    }

    test();
</script>
</body>
</html>

Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

shmishra99 commented 1 month ago

Hi @liliquan0118 ,

I've successfully reproduced the issue you described withtf.cosh.

Output:

the result of  webgl is:
Tensor
     [ [[Infinity],]]

the result of  cpu is:
Tensor
     [ [[Infinity],]]

the result of  wasm is:
Tensor
     [ [[Infinity],]]

Thank You!!