解決策。NotImplementedError: Cannot convert a symbolic tf.Tensor (ArgMax:0) to a numpy array.
エラーの内容
NotImplementedError: Cannot convert a symbolic tf.Tensor (ArgMax:0) to a numpy array.
エラー詳細。
Traceback (most recent call last): File "tf_trans.py", line 54, in <module> predicted_class_name = imagenet_labels[predicted_class] File "C:\Users\XYZZ0\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\ops.py", line 927, in __array__ f"Cannot convert a symbolic tf.Tensor ({self.name}) to a numpy array." NotImplementedError: Cannot convert a symbolic tf.Tensor (ArgMax: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.
解決策
原因は、誤って、以下の一行が入っていたため。
tf.compat.v1.disable_eager_execution()
申し遅れましたが。。。。環境としては、
tensorflow 2.9.1 tensorflow-hub 0.12.0
です。
コメント
コメントなどあれば、お願いします。