Cannot convert a symbolic Tensor to a numpy array

柔情只为你懂 2023-01-17 09:23 260阅读 0赞

使用TF进行计算,出现:

  1. Traceback (most recent call last):
  2. File "infer.py", line 14, in <module>
  3. logits = classifier.get_output_for(image, None)
  4. File "/opt/stylegan2/dnnlib/tflib/network.py", line 219, in get_output_for
  5. expr = tf.zeros([tf.shape(valid_inputs[0])[0]] + shape[1:], name=name)
  6. File "/opt/AN/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 2338, in zeros
  7. output = _constant_if_small(zero, shape, dtype, name)
  8. File "/opt/AN/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 2295, in _constant_if_small
  9. if np.prod(shape) < 1000:
  10. File "<__array_function__ internals>", line 6, in prod
  11. File "/opt/AN/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 3031, in prod
  12. keepdims=keepdims, initial=initial, where=where)
  13. File "/opt/AN/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 87, in _wrapreduction
  14. return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
  15. File "/opt/AN/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 736, in __array__
  16. " array.".format(self.name))
  17. NotImplementedError: Cannot convert a symbolic Tensor (celebahq-classifier-20-goatee_1/strided_slice:0) to a numpy array.

解决方式,降低版本numpy版本

  1. pip install numpy==1.19.5

发表评论

表情:
评论列表 (有 0 条评论,260人围观)

还没有评论,来说两句吧...

相关阅读