Tensorflow警告:无法按拓扑顺序对图进行排序? [英] Tensorflow warning: The graph couldn't be sorted in topological order?

查看:2049
本文介绍了Tensorflow警告:无法按拓扑顺序对图进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行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.

作为一个例子,考虑一个非常小的图形,它具有两个顶点uv,以及两个边线u -> vv -> 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆