我的问题是关于tf.name_scope在教程代码ptb/reader.py中的使用,
with tf.name_scope(name, "PTBProducer", [raw_data, batch_size, num_steps]):
#use raw_data, batch_size, num_steps to construct tf objects 用列表tf.name_scope调用raw_data、batch_size、num_steps的目的是什么?raw_data是一个python列表,batch_size和num_steps是python。根据作用域的文档:
tf.name_scope(name, default_name=None, values=None): This context manager validates that the given values are from the same graph, makes that graph the default graph, and pushes a name scope in that graph (see Graph.name_scope() for more details on that).
但是raw_data、batch_size、num_step不是图中的任何节点。验证它们来自同一张图是什么意思?实际上,当从tf.name_scope调用中删除列表时,代码仍然运行:
with tf.name_scope(name, "PTBProducer"):
#use raw_data, batch_size, num_steps to construct tf objects 调用带有和不带tf.name_scope的values=[raw_data,batch_size,num_steps]有什么区别
发布于 2017-02-28 14:45:37
is不正确地使用了tf.name_scope() 值参数。应该传递图形元素。
name_scope()将使默认的图形上下文与传入元素的图形匹配。如果您正在处理多个图,这是非常有用的。
如果tf.name_scope的值列表(图元素)并非都来自同一个图,则会引发错误。
https://stackoverflow.com/questions/41646532
复制相似问题