a6657266的个人博客分享 http://blog.sciencenet.cn/u/a6657266

博文

python theano中的四个模式

已有 6786 次阅读 2013-7-11 21:21 |系统分类:科研笔记| Python, 四个模式

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()




https://wap.sciencenet.cn/blog-571755-707268.html

上一篇:python计算导数jacobian以及hessian
下一篇:python theano中文件的加载和关闭
收藏 IP: 210.72.26.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-12 14:30

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部