首页 > 解决方案 > Keras.backend.constant() 错误(无法将符号张量(Shape_1:0)转换为 numpy 数组)

问题描述

我正在尝试创建一个具有恒定值的张量。我这样做了

img_shape = K.shape(ground_truth)
random_val = random.uniform(0,1)
random_tensor = K.constant(random_val,shape = img_shape)

我收到一个错误

NotImplementedError: Cannot convert a symbolic Tensor (Shape_1:0) to a numpy array.

ground_truthtensorflow.python.framework.ops.Tensor形状是<tf.Tensor 'Shape_2:0' shape=(3,) dtype=int32>。谢谢!

标签: pythontensorflow

解决方案


推荐阅读