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

tfvis.metrics.confusionMatrix leaks tensors #7961

Open
alvinleung1996 opened this issue Sep 15, 2023 · 1 comment
Open

tfvis.metrics.confusionMatrix leaks tensors #7961

alvinleung1996 opened this issue Sep 15, 2023 · 1 comment
Assignees

Comments

@alvinleung1996
Copy link

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS 13.5.2 (22G91)
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
  • TensorFlow.js installed from (npm or script link): script link
  • TensorFlow.js version (use command below): 4.11.0
  • Browser version: Google Chrome Version 116.0.5845.187 (Official Build) (x86_64)
  • Tensorflow.js Converter Version: N/A

Describe the current behavior

2 Tensors are leaked after calling tfvis.metrics.confusionMatrix.

Describe the expected behavior

No tensor is leaked after calling tfvis.metrics.confusionMatrix.

Standalone code to reproduce the issue

Open Google Chrome, navigate to about:blank, then paste the following code in the console.

await import('https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js')
await import('https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tfjs-vis.umd.min.js')

console.log('num of tensors before:', tf.memory().numTensors);

const labels = tf.tensor1d([0]);
const predictions = tf.tensor1d([0]);
const confusionMatrix = await tfvis.metrics.confusionMatrix(labels, predictions);

labels.dispose();
predictions.dispose();

console.log('num of tensors after:', tf.memory().numTensors)

Other info / logs

Console logs:

num of tensors before: 0
num of tensors after: 2
@alvinleung1996 alvinleung1996 added the type:bug Something isn't working label Sep 15, 2023
@gaikwadrahul8 gaikwadrahul8 self-assigned this Sep 15, 2023
@gaikwadrahul8
Copy link
Contributor

gaikwadrahul8 commented Sep 15, 2023

Hi, @alvinleung1996

Thank you for bringing this issue to our attention and I have attempted to replicate the issue on my end and have observed the same behaviour which you mentioned above in the issue template so we'll have to dig more into this issue and will update you soon, I really appreciate your time and efforts for bringing this issue to our attention. Thank you!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants