Nicolas Gervais
Nicolas Gervais

Reputation: 36704

tf.ones returns zeros instead of ones

Why is tf.ones returning zeros? My version is '2.3.0' and I'm using an Anaconda environment.

import tensorflow as tf

tf.ones((3, 3))
<tf.Tensor: shape=(3, 3), dtype=float32, numpy=
array([[0., 0., 0.],
       [0., 0., 0.],
       [0., 0., 0.]], dtype=float32)>

I don't understand what's going on... But if I use dtype tf.int32 it works:

tf.ones((3, 3), dtype=tf.int32)
<tf.Tensor: shape=(3, 3), dtype=int32, numpy=
array([[1, 1, 1],
       [1, 1, 1],
       [1, 1, 1]])>

Someone here had the same issue.

Upvotes: 1

Views: 227

Answers (1)

Yuri Kreinin
Yuri Kreinin

Reputation: 158

Perhaps, your Python installation doesn't support tensorflow 2.3.0. For instance, Anaconda works properly only with TF 2.1.0

Upvotes: 1

Related Questions