python - 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_truth
的tensorflow.python.framework.ops.Tensor
形状是<tf.Tensor 'Shape_2:0' shape=(3,) dtype=int32>
。谢谢!
解决方案
推荐阅读
- laravel - I want to calculate the total work_time of DB
- java - Spring Boot 和 Logback 中不同 Classloader 加载的类
- python-3.x - 为什么更新后我的全局变量还是一样
- python - 在 for 循环中使用 if...else 返回一个字符串
- r - 可以有没有任何功能的 R 包吗?
- java - 我正在尝试进行聊天活动,用户可以在其中进行个人聊天。但是有些如何仅从数据库中检索单个数据
- python - 如何从第 x 行开始写入 CSV?
- c# - BasicPublish() 的可靠性如何?
- c - C中的字符置换算法,将输出存储在数组中
- mysql - 如何使用spring应用程序中的键将缓存的mysql数据作为redis缓存中的单个项目读取