The expected output for indices is list(indices[12:18]) =[array([26]), array([18]), array([53]), array([27]), array([40]), array([7])]
what I got is a bit difference
list(indices[12:18]) = [<tf.Tensor: shape=(1,), dtype=int64, numpy=array([68])>, <tf.Tensor: shape=(1,), dtype=int64, numpy=array([45])>, <tf.Tensor: shape=(1,), dtype=int64, numpy=array([20])>, <tf.Tensor: shape=(1,), dtype=int64, numpy=array([17])>, <tf.Tensor: shape=(1,), dtype=int64, numpy=array([73])>, <tf.Tensor: shape=(1,), dtype=int64, numpy=array([86])>]
I checked the type of indices:
print(âindices type:â, type(indices)) and It says
indices type: <class âtensorflow.python.framework.ops.EagerTensorâ>
Thank you for the explanation.
Yes. When I replace tf.math.argmax (suggested to be used in Exercise2 2D) with np.argmax, in Execise3 step2 then I get the expected array representation
I then go back to Exerciser2 2D and try to replace tf.math.argmax with np.argmax, I get this error:
âNotImplementedError: Cannot convert a symbolic Tensor (dense/Softmax_132:0) to a numpy array. This error may indicate that youâre trying to pass a Tensor to a NumPy call, which is not supportedâ
So it looks like that if inputs to the argmax is a tf tensor, then we should use tf.math.argmax instead of np.argmax