通过一个会话在张量流中执行多个模型 [英] executing multiple models in tensorflow with a single session
问题描述
我正在尝试在张量流中并行运行多个神经网络模型,每个模型都独立于其余模型.有必要为我使用tensorflow启动的每个执行创建一个会话,否则我可以为每个模型?重用同一会话.谢谢
I'm trying to run several models of neural networks in tensorflow in parallel, each model is independent of the rest. It is necessary to create a session for each of the executions I launch with tensorflow or I could reuse the same session for each of the models ?. Thank you
推荐答案
会话链接到特定的Tensorflow Graph
实例.如果要全部进行一次会话,则需要将所有模型放在同一图中.这可能会导致您为张量命名问题,并且IMO通常不是一个好主意(您应将互不相关的事物分开放置).
A session is linked to a specific Tensorflow Graph
instance. If you want to have one session for all, you need to put all your models in the same graph. This may cause you naming problems for tensors and is IMO generally a bad idea (you should keep things that are not related to each other separate).
在同一图形中包含所有内容也提高了模型的资源要求(即使只运行一个子图形,也始终加载所有内容),这是将事物拆分为独立图形的另一个原因.对于独立的图,您将不得不使用多个会话.
Having everything in the same graph also raises your model's resources requirements (you always load everything even if you run only a sub-graph), which is another reason to split things in independent graphs. With independent graphs, you'll have to use multiple sessions.
这篇关于通过一个会话在张量流中执行多个模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!