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

When setting the pad to a number, the result of tf.avgPool3d is abnormal. #7122

Closed
liliquan0118 opened this issue Nov 29, 2022 · 1 comment · Fixed by #7133
Closed

When setting the pad to a number, the result of tf.avgPool3d is abnormal. #7122

liliquan0118 opened this issue Nov 29, 2022 · 1 comment · Fixed by #7133
Assignees
Labels
type:bug Something isn't working

Comments

@liliquan0118
Copy link

liliquan0118 commented Nov 29, 2022

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

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):Linux Ubuntu 20.04
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow.js installed from (npm or script link):script link
  • TensorFlow.js version (use command below):4.1.0
  • Browser version:chrome 106.0.5249.119
  • Tensorflow.js Converter Version:

Describe the current behavior
The API document of Tensorflow.js states that the parameter pad in operator tf.avgPool3d can be data of type number. But when setting the pad to a number, the result is abnormal.
image

When running on the backend CPU, the values of output tensor are all NaN;
Selection_058

When running on the backend WebGL, the values of output tensor are all 0 ;
Selection_059

When running on the backend Tensorflow, the error is thrown with error message "TF Backend supports only 'valid' and 'same' padding while padding was NUMBER";
Selection_061

When running on the backend wasm, the error is thrown with error message "Kernel 'AvgPool3D' not registered for backend 'wasm'";

Describe the expected behavior
The implementation of tf.avgPool3d should be consistent across all backends and should be consistent with the description in the API documentation. In addition, when pad is set to a number, the operator tf.avgPool3d should give the correct output instead of a tensor with the value 0 or NaN for any input.

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>bug7122</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs/dist/tf.js"> </script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm/dist/tf-backend-wasm.js"></script>
<script>
    function avgPool3d(backend){
        tf.setBackend(backend);
        tf.ready().then(()=>{
            const output = tf.avgPool3d([[[[[1,2,3],[4,5,6],[7,8,9]],[[1,2,3],[4,5,6],[7,8,9]],[[1,2,3],[4,5,6],[7,8,9]]],[[[1,2,3],[4,5,6],[7,8,9]],[[1,2,3],[4,5,6],[7,8,9]],[[1,2,3],[4,5,6],[7,8,9]]],[[[1,2,3],[4,5,6],[7,8,9]],[[1,2,3],[4,5,6],[7,8,9]],[[1,2,3],[4,5,6],[7,8,9]]]]],[1,2,2], 1, 3,"floor","NDHWC");
            output.print();
        })
    }
    async function run(){
        await avgPool3d("cpu");
        await avgPool3d("webgl");
    }
    run();

</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.

@liliquan0118 liliquan0118 added the type:bug Something isn't working label Nov 29, 2022
@Linchenn Linchenn self-assigned this Nov 30, 2022
@Linchenn Linchenn mentioned this issue Dec 1, 2022
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants