TensorFlow学习之会话Sesstion()和交互会话InterativeSesstion()

本文对比了TensorFlow中Session和InteractiveSession的区别。InteractiveSession允许直接运行变量,无需频繁引用会话对象;Session则需在with语句中使用,并显式关闭。文章详细解释了两种会话的不同之处。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天学习tensorflow时发现除了Session()外,竟然还有个InteractiveSession()。这就让我这个初学者又开始抓耳挠腮的想了,这两者有什么不同呢,还要设置两个会话类型。现在将其两者的差别简单写一下,后期根据自己的学习状态及理解会不断的更新。

在教学网站上看到一段对InteractiveSession()的描述语:
One major change is the use of an InteractiveSession, which allows us to run variables without needing to constantly refer to the session object (less typing!). Code blocks below are broken into different cells. If you see a break in the code, you will need to run the previous cell first. Also, if you aren’t otherwise confident, ensure all of the code in a given block is type into a cell before you run it.

不同点1、

最为主要的一句话当属第一句:使用InteractiveSession一个主要的变化是:运行在没有指定会话对象的情况下运行变量。这是与Session()最大的不同。

不同点2、

Session()使用with..as..后可以不使用close关闭对话,而调用InteractiveSession需要在最后调用close

转载:http://blog.youkuaiyun.com/u010417185/article/details/51909462

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值