I want to exchange Tensor
a
to a NumPy two-dimensional array for getting a heat map.
(Tensor(1, 64, 64, 1) -> numpy (64, 64))
I tried x.numpy()
, but it doesn't work. The error message is this:
AttributeError: in user code: :187 call * x_np=x.numpy() /usr/local/lib/python3.7/dist packages/tensorflow/python/framework/ops.py:401 getattr self.getattribute(name) AttributeError: 'Tensor' object has no attribute 'numpy'
This is the tensor information and type of the tensor:
Tensor("ExpandDims:0", shape=(1, 64, 64, 1), dtype=float32)
<class 'tensorflow.python.framework.ops.Tensor'>
and I don't know what ExpandDims:0
means (what is this argv?).
Tensorflow:2.6.0
Numpy:1.21.2
I made the test code that has the same Tensor type, shape, and env, and it works.
What should I do?
import tensorflow as tf
import numpy
print(tf.__version__)
print(numpy.__version__)
a = tf.constant([[[[0.1]*1]*64]*64])
print(a)
print(a.numpy())