mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-29 21:13:37 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
import theano
|
||||
import theano.tensor as T
|
||||
|
||||
@@ -14,7 +14,7 @@ print theano.config
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
floatX (('float64', 'float32', 'float16'))
|
||||
Doc: Default floating-point precision for python casts.
|
||||
|
||||
@@ -562,7 +562,7 @@ lib.cnmem (<type 'float'>)
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
Using gpu device 1: Tesla K10.G2.8GB (CNMeM is disabled)
|
||||
|
||||
```
|
||||
@@ -583,13 +583,13 @@ Using gpu device 1: Tesla K10.G2.8GB (CNMeM is disabled)
|
||||
|
||||
使用 `THEANO_FLAGS` 环境变量,运行程序的方法如下:
|
||||
|
||||
```
|
||||
```py
|
||||
THEANO_FLAGS='floatX=float32,device=gpu0,nvcc.fastmath=True' python <myscript>.py
|
||||
```
|
||||
|
||||
如果是 `window` 下,则需要进行稍微的改动:
|
||||
|
||||
```
|
||||
```py
|
||||
set THEANO_FLAGS='floatX=float32,device=gpu0,nvcc.fastmath=True' && python <myscript>.py
|
||||
```
|
||||
|
||||
@@ -601,7 +601,7 @@ set THEANO_FLAGS='floatX=float32,device=gpu0,nvcc.fastmath=True' && python <mysc
|
||||
|
||||
与前面 `THEANO_FLAGS` 指定的内容相同的配置文件为:
|
||||
|
||||
```
|
||||
```py
|
||||
[global]
|
||||
floatX = float32
|
||||
device = gpu0
|
||||
@@ -651,7 +651,7 @@ fastmath = True
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
x = T.dvector('x')
|
||||
|
||||
f_1 = theano.function([x], 10 / x)
|
||||
@@ -662,7 +662,7 @@ print f_1([7])
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[ 2.]
|
||||
[ inf]
|
||||
[ 1.42857143]
|
||||
@@ -673,7 +673,7 @@ print f_1([7])
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
f_2 = theano.function([x], 10 / x, mode='DebugMode')
|
||||
|
||||
print f_2([5])
|
||||
@@ -682,12 +682,12 @@ print f_2([7])
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[ 2.]
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
---------------------------------------------------------------------------
|
||||
InvalidValueError Traceback (most recent call last)
|
||||
<ipython-input-3-ad8c4ba988ad> in <module>()
|
||||
|
||||
Reference in New Issue
Block a user