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中文件的加载和关闭