theano程序(三)

# -*- coding: utf-8 -*-


#使用CPU还是GPU依赖于你的.theanorc文件中定义的环境变量。

#当前,应该使用GPU定义的float32,但大多数人喜欢使用CPU定义的float64

#theano提供了配置变量floatX 来设置到底使用GPU还是CPU

#为了看得清楚,我的电脑上的.theanorc文件内容列出来,内容如下:

'''

# 文件C:\Documents and Settings\sf\.theanorc.txt的内容如下,则设置成GPU

#设置完成后,需要注销当前windows用户重新登录才能生效.

#sf是电脑上的用户名。

[global]

openmp=False

floatX = float32

device = gpu0

[blas]

ldflags=

[gcc]

cxxflags = -IC:\MinGW\include

'''

源程序如下:


import theano

print theano.config.device

print theano.config.floatX


'''显示内容为

gpu0

float32

'''


'''

# 文件C:\Documents and Settings\sf\.theanorc.txt的内容修改如下,也即采用默认值:

[global]

openmp=False

[blas]

ldflags=

[gcc]

cxxflags = -IC:\MinGW\include

'''

'''

源程序如下:

print theano.config.device

print theano.config.floatX

'''

'''显示内容为

cpu

float64

'''


# 也可以在运行过程中 获取和设置floatX的值

old_floatX = theano.config.floatX

theano.config.floatX = 'float64'

print theano.config.device

print theano.config.floatX

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值