python - 如何在张量流中重用占位符?
问题描述
我试图为不同形状的输入重用占位符但失败了。而我在网上搜索答案,只发现如何通过variable_scope("",reuse=tf.AUTO_REUSE)重用变量。我尝试了同样的方法,但它不起作用。Python 抛出异常“ValueError: Duplicate node name in graph: 'input_image'”。我很困惑,并提前感谢您的帮助。
比如我想训练一个图片为128*128的网络,我想测试一个图片为1080*960的网络:
with tf.variable_scope('test/', reuse=tf.AUTO_REUSE):
input_image = tf.placeholder(shape=[batch_size, 128, 128, 3], dtype=tf.float32, name='input_image/')
aug_image= train_net(input_image)
sess = tf.Session()
init = tf.global_variables_initializer()
sess.run(init)
for i in range(100000):
augg = sess.run([aug_image],feed_dict={input_image: tmp})
if i % 1000 == 0:
with tf.variable_scope('test/', reuse=True):
input_image = tf.placeholder(shape=[1, 1080, 960, 3],dtype=tf.float32,name='input_image/')
aug = sess.run([aug_image],{input_image: pic1})
show(aug)
解决方案
推荐阅读
- amazon-web-services - Error in Call to Sagemaker Endpoint with Lambda and API Gateway
- ios - 我怎样才能提高它的性能......为什么没有 LazyZStack 这样的东西?
- firebase - 如何在 Firestore 集合中检索文档的 documentId,以便在返回对象流的 getter 中使用它
- c++ - 单例和新运算符 - 线程安全
- c - 如何在C中清除控制台而不闪烁
- python - 使用 python 从 Cassandra 数据库中检索数据
- database - 我可以为 MongoDB 索引配置特定路径吗?
- html - 如何对齐网格系统html/css?
- docker - 无法到达 docker 容器 - 端口未绑定
- html - 响应式列,防止孩子在折叠时在列之间移动