Skip to content

Commit

Permalink
Fixed NotImplementedError: Cannot convert a symbolic Tensor to a nump…
Browse files Browse the repository at this point in the history
…y array
  • Loading branch information
petronny committed Apr 14, 2021
1 parent 8f46088 commit 0494c90
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tensorflow/python/ops/array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from tensorflow.python.framework.constant_op import constant
from tensorflow.python.ops import gen_array_ops
from tensorflow.python.ops import gen_math_ops
from tensorflow.python.ops.math_ops import reduce_prod
# go/tf-wildcard-import
# pylint: disable=wildcard-import
from tensorflow.python.ops.gen_array_ops import *
Expand Down Expand Up @@ -2893,7 +2894,7 @@ def matrix_set_diag(

def _constant_if_small(value, shape, dtype, name):
try:
if np.prod(shape) < 1000:
if reduce_prod(shape).eval() < 1000:
return constant(value, shape=shape, dtype=dtype, name=name)
except TypeError:
# Happens when shape is a Tensor, list with Tensor elements, etc.
Expand Down

0 comments on commit 0494c90

Please sign in to comment.