theano程序(三)

来源:互联网 发布:qq牧场飞鸟升级数据 编辑:程序博客网 时间:2024/05/09 11:48
# -*- 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
原创粉丝点击