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

Tensor.tensorOf methods can return unzeroed memory #271

Open
Craigacp opened this issue Apr 2, 2021 · 0 comments
Open

Tensor.tensorOf methods can return unzeroed memory #271

Craigacp opened this issue Apr 2, 2021 · 0 comments

Comments

@Craigacp
Copy link
Collaborator

Craigacp commented Apr 2, 2021

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yep
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 0.3.1

Describe the current behavior

Tensor.of(Class,Shape,long) and Tensor.of(Class,Shape) return a Tensor which has not been zeroed. This is used by the various tensorOf methods on things like TFloat32.

Describe the expected behavior

Tensors should be initialised to be all zero the same way any other Java object is.

Code to reproduce the issue

Run TFloat32.tensorOf(Shape.of(2,2)) and you'll likely get some junk in there. I was allocating things (16,10) but the size is irrelevant.

I was building a one hot vector to use as the target for a training run, and I expected to get an all zero tensor back, so I only set the 1s. The model was very confused by the true labels having NaNs in.

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

No branches or pull requests

1 participant