python theano 关系_科学网—python theano中的四个模式 - 于博的博文

FAST_COMPILE

FAST_RUN

DebugMode

ProfileMode

通常情况下,我们都是用FAST_COMPILE以及FAST_RUN模式

DebugMode下有自检功能,可以诊断可能存在的程序错误。由于DebugMode要比FAST_RUN以及FAST_COMPILE慢,所以只能用来development过程中使用

x=T.dvector('x')

f=function([x],10*x,mode='DebugMode')

ProfileMode是用来分析代码的模式

创建ProfileMode的一个实例

from theano import ProfileMode

profmode=theano.ProfileMode(optimizer='fast_run',linker=theano.gof.OpWiseClinker())

ProfileMode构建需要两个输入变量,一个是optimizer,一个是linker,如果只想在python下运行,就用gof.PerformLinker,如果想再C下运行,就用gof.OpWiseCLinker,如果想检测运行的速度,要用fast_run optimizer 和 gof.OpWiseCLinker linker

f=function([input],output,mode=profmode)

m=theano.Module()

minst=m.make(mode=profmode)

如果想要知道代码各个部分运行的时间

profmode.print_summary()

转载本文请联系原作者获取授权,同时请注明本文来自于博科学网博客。

链接地址:http://blog.sciencenet.cn/blog-571755-707268.html

上一篇:python计算导数jacobian以及hessian

下一篇:python theano中文件的加载和关闭

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值