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:
@@ -2,14 +2,14 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
import theano
|
||||
import theano.tensor as T
|
||||
import numpy as np
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
Using gpu device 1: Tesla C2075 (CNMeM is disabled)
|
||||
|
||||
```
|
||||
@@ -20,14 +20,14 @@ Using gpu device 1: Tesla C2075 (CNMeM is disabled)
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
t = T.arange(9)
|
||||
|
||||
print t[1::2].eval()
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[1 3 5 7]
|
||||
|
||||
```
|
||||
@@ -36,14 +36,14 @@ print t[1::2].eval()
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
n = np.arange(9)
|
||||
|
||||
print n[1::2]
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[1 3 5 7]
|
||||
|
||||
```
|
||||
@@ -54,14 +54,14 @@ print n[1::2]
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
t = T.arange(9).reshape((3,3))
|
||||
|
||||
print t[t > 4].eval()
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[[[0 1 2]
|
||||
[0 1 2]
|
||||
[0 1 2]]
|
||||
@@ -80,14 +80,14 @@ print t[t > 4].eval()
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
n = np.arange(9).reshape((3,3))
|
||||
|
||||
print n[n > 4]
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[5 6 7 8]
|
||||
|
||||
```
|
||||
@@ -96,12 +96,12 @@ print n[n > 4]
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
print t[(t > 4).nonzero()].eval()
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[5 6 7 8]
|
||||
|
||||
```
|
||||
@@ -118,7 +118,7 @@ print t[(t > 4).nonzero()].eval()
|
||||
|
||||
In [7]:
|
||||
|
||||
```
|
||||
```py
|
||||
r = T.vector()
|
||||
|
||||
new_r = T.set_subtensor(r[10:], 5)
|
||||
@@ -131,7 +131,7 @@ new_r = T.set_subtensor(r[10:], 5)
|
||||
|
||||
In [8]:
|
||||
|
||||
```
|
||||
```py
|
||||
r = T.vector()
|
||||
|
||||
new_r = T.inc_subtensor(r[10:], 5)
|
||||
|
||||
Reference in New Issue
Block a user