Tensorflow警告:无法按拓扑顺序对图进行排序? [英] Tensorflow warning: The graph couldn't be sorted in topological order?
问题描述
当我运行tensorflow
训练(带有自定义定义的图形,封闭源代码)时,它会输出警告:
When I run tensorflow
training (with custom defined graph, closed source), it outputs the warning:
2018-10-03 14:29:24.352895:E tensorflow/core/grappler/optimizers/dependency_optimizer.cc:666]迭代= 0,拓扑排序失败,并显示以下消息:无法按拓扑顺序对图形进行排序.
2018-10-03 14:29:24.352895: E tensorflow/core/grappler/optimizers/dependency_optimizer.cc:666] Iteration = 0, topological sort failed with message: The graph couldn't be sorted in topological order.
是什么意思?可能导致此问题的原因以及如何避免它?
What does it mean? What could likely cause this problem and how to avoid it?
更新:就我而言,尽管有此警告,但tensorflow
仍可以正常工作.因此,我认为这只是意味着计算图中的循环要多于tensorflow
的预期,而不一定是无限循环.我通过避免在代码中使用手动循环来解决此问题,而是使用张量操纵(stack, concat, slice, reshape...
)
Update: For the record, in my case, tensorflow
still works correctly despite this warning. So I think it just means there are more loops in the computation graph than what tensorflow
expects, not necessarily infinite loop. I fixed this by avoid using manual loop in code, but instead using tensor manipulation (stack, concat, slice, reshape...
)
推荐答案
A的拓扑排序有向图是其顶点的排序方式,使得只要有从顶点u
到顶点v
的边,顶点u
就会在该顺序的顶点v
之前出现.
A topological ordering of a directed graph is an ordering of its vertices in such a way that whenever there is an edge from vertex u
to vertex v
, vertex u
comes before vertex v
in the ordering.
每种有向 acyclic 图都可以进行这种排序,但任意图都不能.图中很可能存在某种循环,导致排序算法无法成功执行.因此,解决方法是搜索周期并以某种方式将其删除.
This kind of ordering is possible for every directed acyclic graph but not for arbitrary graphs. There is most likely some kind of cycle in your graph that prevents the sorting algorithm from succeeding. So, the way to go is searching for the cycle and removing it in some way.
作为一个例子,考虑一个非常小的图形,它具有两个顶点u
和v
,以及两个边线u -> v
和v -> u
.无法按照上述要求对u和v进行排序.
As an example, consider a very small graph with two vertices, u
and v
, and two edges, u -> v
and v -> u
. There is no way to sort u and v in accordance with the requirements given above.
没有有关代码的更多信息,很难确切说明正在发生什么.
Without further information on your code it is hard to say exactly what is going on.
这篇关于Tensorflow警告:无法按拓扑顺序对图进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!