Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0784ab7b
提交
0784ab7b
authored
4月 11, 2017
作者:
Frédéric Bastien
提交者:
GitHub
4月 11, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5829 from Amrithasuresh/master
Updated numpy as np #4218
上级
28c886fc
ed499576
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
59 行增加
和
59 行删除
+59
-59
ifelse_switch.py
doc/crei2013/ifelse_switch.py
+3
-3
logreg.py
doc/crei2013/logreg.py
+2
-2
scan_poly.py
doc/crei2013/scan_poly.py
+2
-2
extending_theano_solution_1.py
doc/extending/extending_theano_solution_1.py
+23
-23
double_op.py
doc/hpcs2011_tutorial/double_op.py
+3
-3
logreg_example.py
doc/hpcs2011_tutorial/logreg_example.py
+3
-3
pycuda_simple.py
doc/hpcs2011_tutorial/pycuda_simple.py
+5
-5
scan_poly.py
doc/hpcs2011_tutorial/scan_poly.py
+2
-2
logreg.py
doc/omlw2014/logreg.py
+2
-2
loop_solution_1.py
doc/tutorial/loop_solution_1.py
+4
-4
modes_solution_1.py
doc/tutorial/modes_solution_1.py
+3
-3
profiling_example.py
doc/tutorial/profiling_example.py
+4
-4
using_gpu_solution_1.py
doc/tutorial/using_gpu_solution_1.py
+3
-3
没有找到文件。
doc/crei2013/ifelse_switch.py
浏览文件 @
0784ab7b
from
__future__
import
absolute_import
,
print_function
,
division
import
time
import
numpy
import
numpy
as
np
import
theano
from
theano
import
tensor
as
tt
...
...
@@ -19,8 +19,8 @@ f_lazyifelse = theano.function([a, b, x, y], z_lazy)
val1
=
0.
val2
=
1.
big_mat1
=
n
umpy
.
ones
((
10000
,
1000
))
big_mat2
=
n
umpy
.
ones
((
10000
,
1000
))
big_mat1
=
n
p
.
ones
((
10000
,
1000
))
big_mat2
=
n
p
.
ones
((
10000
,
1000
))
n_times
=
10
...
...
doc/crei2013/logreg.py
浏览文件 @
0784ab7b
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
import
theano.tensor
as
tt
rng
=
n
umpy
.
random
rng
=
n
p
.
random
N
=
400
feats
=
784
...
...
doc/crei2013/scan_poly.py
浏览文件 @
0784ab7b
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
import
theano.tensor
as
tt
...
...
@@ -19,6 +19,6 @@ polynomial = components.sum()
calculate_polynomial
=
theano
.
function
(
inputs
=
[
coefficients
,
x
],
outputs
=
polynomial
)
test_coeff
=
n
umpy
.
asarray
([
1
,
0
,
2
],
dtype
=
numpy
.
float32
)
test_coeff
=
n
p
.
asarray
([
1
,
0
,
2
],
dtype
=
np
.
float32
)
print
(
calculate_polynomial
(
test_coeff
,
3
))
# 19.0
doc/extending/extending_theano_solution_1.py
浏览文件 @
0784ab7b
...
...
@@ -85,7 +85,7 @@ class SumDiffOp(theano.Op):
# 3. Testing apparatus
import
numpy
import
numpy
as
np
from
theano.gof
import
Op
,
Apply
from
theano
import
tensor
,
function
,
printing
from
theano.tests
import
unittest_tools
as
utt
...
...
@@ -93,7 +93,7 @@ from theano.tests import unittest_tools as utt
class
TestProdOp
(
utt
.
InferShapeTester
):
rng
=
n
umpy
.
random
.
RandomState
(
43
)
rng
=
n
p
.
random
.
RandomState
(
43
)
def
setUp
(
self
):
super
(
TestProdOp
,
self
)
.
setUp
()
...
...
@@ -103,14 +103,14 @@ class TestProdOp(utt.InferShapeTester):
x
=
theano
.
tensor
.
matrix
()
y
=
theano
.
tensor
.
matrix
()
f
=
theano
.
function
([
x
,
y
],
self
.
op_class
()(
x
,
y
))
x_val
=
n
umpy
.
random
.
rand
(
5
,
4
)
y_val
=
n
umpy
.
random
.
rand
(
5
,
4
)
x_val
=
n
p
.
random
.
rand
(
5
,
4
)
y_val
=
n
p
.
random
.
rand
(
5
,
4
)
out
=
f
(
x_val
,
y_val
)
assert
n
umpy
.
allclose
(
x_val
*
y_val
,
out
)
assert
n
p
.
allclose
(
x_val
*
y_val
,
out
)
def
test_gradient
(
self
):
utt
.
verify_grad
(
self
.
op_class
(),
[
n
umpy
.
random
.
rand
(
5
,
4
),
n
umpy
.
random
.
rand
(
5
,
4
)],
utt
.
verify_grad
(
self
.
op_class
(),
[
n
p
.
random
.
rand
(
5
,
4
),
n
p
.
random
.
rand
(
5
,
4
)],
n_tests
=
1
,
rng
=
TestProdOp
.
rng
)
def
test_infer_shape
(
self
):
...
...
@@ -118,14 +118,14 @@ class TestProdOp(utt.InferShapeTester):
y
=
tensor
.
dmatrix
()
self
.
_compile_and_check
([
x
,
y
],
[
self
.
op_class
()(
x
,
y
)],
[
n
umpy
.
random
.
rand
(
5
,
6
),
n
umpy
.
random
.
rand
(
5
,
6
)],
[
n
p
.
random
.
rand
(
5
,
6
),
n
p
.
random
.
rand
(
5
,
6
)],
self
.
op_class
)
class
TestSumDiffOp
(
utt
.
InferShapeTester
):
rng
=
n
umpy
.
random
.
RandomState
(
43
)
rng
=
n
p
.
random
.
RandomState
(
43
)
def
setUp
(
self
):
super
(
TestSumDiffOp
,
self
)
.
setUp
()
...
...
@@ -135,10 +135,10 @@ class TestSumDiffOp(utt.InferShapeTester):
x
=
theano
.
tensor
.
matrix
()
y
=
theano
.
tensor
.
matrix
()
f
=
theano
.
function
([
x
,
y
],
self
.
op_class
()(
x
,
y
))
x_val
=
n
umpy
.
random
.
rand
(
5
,
4
)
y_val
=
n
umpy
.
random
.
rand
(
5
,
4
)
x_val
=
n
p
.
random
.
rand
(
5
,
4
)
y_val
=
n
p
.
random
.
rand
(
5
,
4
)
out
=
f
(
x_val
,
y_val
)
assert
n
umpy
.
allclose
([
x_val
+
y_val
,
x_val
-
y_val
],
out
)
assert
n
p
.
allclose
([
x_val
+
y_val
,
x_val
-
y_val
],
out
)
def
test_gradient
(
self
):
def
output_0
(
x
,
y
):
...
...
@@ -147,11 +147,11 @@ class TestSumDiffOp(utt.InferShapeTester):
def
output_1
(
x
,
y
):
return
self
.
op_class
()(
x
,
y
)[
1
]
utt
.
verify_grad
(
output_0
,
[
n
umpy
.
random
.
rand
(
5
,
4
),
n
umpy
.
random
.
rand
(
5
,
4
)],
utt
.
verify_grad
(
output_0
,
[
n
p
.
random
.
rand
(
5
,
4
),
n
p
.
random
.
rand
(
5
,
4
)],
n_tests
=
1
,
rng
=
TestSumDiffOp
.
rng
)
utt
.
verify_grad
(
output_1
,
[
n
umpy
.
random
.
rand
(
5
,
4
),
n
umpy
.
random
.
rand
(
5
,
4
)],
utt
.
verify_grad
(
output_1
,
[
n
p
.
random
.
rand
(
5
,
4
),
n
p
.
random
.
rand
(
5
,
4
)],
n_tests
=
1
,
rng
=
TestSumDiffOp
.
rng
)
def
test_infer_shape
(
self
):
...
...
@@ -161,14 +161,14 @@ class TestSumDiffOp(utt.InferShapeTester):
# adapt the choice of the next instruction to the op under test
self
.
_compile_and_check
([
x
,
y
],
self
.
op_class
()(
x
,
y
),
[
n
umpy
.
random
.
rand
(
5
,
6
),
n
umpy
.
random
.
rand
(
5
,
6
)],
[
n
p
.
random
.
rand
(
5
,
6
),
n
p
.
random
.
rand
(
5
,
6
)],
self
.
op_class
)
# as_op exercice
import
theano
import
numpy
import
numpy
as
np
from
theano.compile.ops
import
as_op
...
...
@@ -180,7 +180,7 @@ def infer_shape_numpy_dot(node, input_shapes):
@as_op
(
itypes
=
[
theano
.
tensor
.
fmatrix
,
theano
.
tensor
.
fmatrix
],
otypes
=
[
theano
.
tensor
.
fmatrix
],
infer_shape
=
infer_shape_numpy_dot
)
def
numpy_add
(
a
,
b
):
return
n
umpy
.
add
(
a
,
b
)
return
n
p
.
add
(
a
,
b
)
def
infer_shape_numpy_add_sub
(
node
,
input_shapes
):
...
...
@@ -192,13 +192,13 @@ def infer_shape_numpy_add_sub(node, input_shapes):
@as_op
(
itypes
=
[
theano
.
tensor
.
fmatrix
,
theano
.
tensor
.
fmatrix
],
otypes
=
[
theano
.
tensor
.
fmatrix
],
infer_shape
=
infer_shape_numpy_add_sub
)
def
numpy_add
(
a
,
b
):
return
n
umpy
.
add
(
a
,
b
)
return
n
p
.
add
(
a
,
b
)
@as_op
(
itypes
=
[
theano
.
tensor
.
fmatrix
,
theano
.
tensor
.
fmatrix
],
otypes
=
[
theano
.
tensor
.
fmatrix
],
infer_shape
=
infer_shape_numpy_add_sub
)
def
numpy_sub
(
a
,
b
):
return
n
umpy
.
sub
(
a
,
b
)
return
n
p
.
sub
(
a
,
b
)
if
__name__
==
"__main__"
:
...
...
doc/hpcs2011_tutorial/double_op.py
浏览文件 @
0784ab7b
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
class
DoubleOp
(
theano
.
Op
):
...
...
@@ -21,8 +21,8 @@ x = theano.tensor.matrix()
f
=
theano
.
function
([
x
],
DoubleOp
()(
x
))
inp
=
n
umpy
.
random
.
rand
(
5
,
5
)
inp
=
n
p
.
random
.
rand
(
5
,
5
)
out
=
f
(
inp
)
assert
n
umpy
.
allclose
(
inp
*
2
,
out
)
assert
n
p
.
allclose
(
inp
*
2
,
out
)
print
(
inp
)
print
(
out
)
doc/hpcs2011_tutorial/logreg_example.py
浏览文件 @
0784ab7b
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
import
theano.tensor
as
T
rng
=
n
umpy
.
random
rng
=
n
p
.
random
N
=
400
feats
=
784
...
...
@@ -13,7 +13,7 @@ training_steps = 10000
x
=
T
.
matrix
(
"x"
)
y
=
T
.
vector
(
"y"
)
w
=
theano
.
shared
(
rng
.
randn
(
feats
)
.
astype
(
theano
.
config
.
floatX
),
name
=
"w"
)
b
=
theano
.
shared
(
n
umpy
.
asarray
(
0.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"b"
)
b
=
theano
.
shared
(
n
p
.
asarray
(
0.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"b"
)
x
.
tag
.
test_value
=
D
[
0
]
y
.
tag
.
test_value
=
D
[
1
]
#print "Initial model:"
...
...
doc/hpcs2011_tutorial/pycuda_simple.py
浏览文件 @
0784ab7b
from
__future__
import
absolute_import
,
print_function
,
division
import
pycuda.autoinit
import
pycuda.driver
as
drv
import
numpy
import
numpy
as
np
from
pycuda.compiler
import
SourceModule
mod
=
SourceModule
(
"""
...
...
@@ -14,13 +14,13 @@ __global__ void multiply_them(float *dest, float *a, float *b)
multiply_them
=
mod
.
get_function
(
"multiply_them"
)
a
=
n
umpy
.
random
.
randn
(
400
)
.
astype
(
numpy
.
float32
)
b
=
n
umpy
.
random
.
randn
(
400
)
.
astype
(
numpy
.
float32
)
a
=
n
p
.
random
.
randn
(
400
)
.
astype
(
np
.
float32
)
b
=
n
p
.
random
.
randn
(
400
)
.
astype
(
np
.
float32
)
dest
=
n
umpy
.
zeros_like
(
a
)
dest
=
n
p
.
zeros_like
(
a
)
multiply_them
(
drv
.
Out
(
dest
),
drv
.
In
(
a
),
drv
.
In
(
b
),
block
=
(
400
,
1
,
1
),
grid
=
(
1
,
1
))
assert
n
umpy
.
allclose
(
dest
,
a
*
b
)
assert
n
p
.
allclose
(
dest
,
a
*
b
)
print
(
dest
)
doc/hpcs2011_tutorial/scan_poly.py
浏览文件 @
0784ab7b
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
import
theano.tensor
as
T
...
...
@@ -18,6 +18,6 @@ polynomial = components.sum()
calculate_polynomial
=
theano
.
function
(
inputs
=
[
coefficients
,
x
],
outputs
=
polynomial
)
test_coeff
=
n
umpy
.
asarray
([
1
,
0
,
2
],
dtype
=
numpy
.
float32
)
test_coeff
=
n
p
.
asarray
([
1
,
0
,
2
],
dtype
=
np
.
float32
)
print
(
calculate_polynomial
(
test_coeff
,
3
))
# 19.0
doc/omlw2014/logreg.py
浏览文件 @
0784ab7b
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
import
theano.tensor
as
tt
rng
=
n
umpy
.
random
rng
=
n
p
.
random
N
=
400
feats
=
784
...
...
doc/tutorial/loop_solution_1.py
浏览文件 @
0784ab7b
...
...
@@ -2,7 +2,7 @@
# Theano tutorial
# Solution to Exercise in section 'Loop'
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
import
theano.tensor
as
tt
...
...
@@ -52,7 +52,7 @@ polynomial = components.sum()
calculate_polynomial1
=
theano
.
function
(
inputs
=
[
coefficients
,
x
],
outputs
=
polynomial
)
test_coeff
=
n
umpy
.
asarray
([
1
,
0
,
2
],
dtype
=
numpy
.
float32
)
test_coeff
=
n
p
.
asarray
([
1
,
0
,
2
],
dtype
=
np
.
float32
)
print
(
calculate_polynomial1
(
test_coeff
,
3
))
# 19.0
...
...
@@ -68,7 +68,7 @@ max_coefficients_supported = 10000
full_range
=
tt
.
arange
(
max_coefficients_supported
)
outputs_info
=
tt
.
as_tensor_variable
(
n
umpy
.
asarray
(
0
,
'float64'
))
outputs_info
=
tt
.
as_tensor_variable
(
n
p
.
asarray
(
0
,
'float64'
))
components
,
updates
=
theano
.
scan
(
fn
=
lambda
coeff
,
power
,
prior_value
,
free_var
:
prior_value
+
(
coeff
*
(
free_var
**
power
)),
...
...
@@ -80,6 +80,6 @@ polynomial = components[-1]
calculate_polynomial
=
theano
.
function
(
inputs
=
[
coefficients
,
x
],
outputs
=
polynomial
,
updates
=
updates
)
test_coeff
=
n
umpy
.
asarray
([
1
,
0
,
2
],
dtype
=
numpy
.
float32
)
test_coeff
=
n
p
.
asarray
([
1
,
0
,
2
],
dtype
=
np
.
float32
)
print
(
calculate_polynomial
(
test_coeff
,
3
))
# 19.0
doc/tutorial/modes_solution_1.py
浏览文件 @
0784ab7b
...
...
@@ -3,13 +3,13 @@
# Solution to Exercise in section 'Configuration Settings and Compiling Modes'
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
import
theano.tensor
as
tt
theano
.
config
.
floatX
=
'float32'
rng
=
n
umpy
.
random
rng
=
n
p
.
random
N
=
400
feats
=
784
...
...
@@ -21,7 +21,7 @@ training_steps = 10000
x
=
tt
.
matrix
(
"x"
)
y
=
tt
.
vector
(
"y"
)
w
=
theano
.
shared
(
rng
.
randn
(
feats
)
.
astype
(
theano
.
config
.
floatX
),
name
=
"w"
)
b
=
theano
.
shared
(
n
umpy
.
asarray
(
0.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"b"
)
b
=
theano
.
shared
(
n
p
.
asarray
(
0.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"b"
)
x
.
tag
.
test_value
=
D
[
0
]
y
.
tag
.
test_value
=
D
[
1
]
#print "Initial model:"
...
...
doc/tutorial/profiling_example.py
浏览文件 @
0784ab7b
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
x
,
y
,
z
=
theano
.
tensor
.
vectors
(
'xyz'
)
f
=
theano
.
function
([
x
,
y
,
z
],
[(
x
+
y
+
z
)
*
2
])
xv
=
n
umpy
.
random
.
rand
(
10
)
.
astype
(
theano
.
config
.
floatX
)
yv
=
n
umpy
.
random
.
rand
(
10
)
.
astype
(
theano
.
config
.
floatX
)
zv
=
n
umpy
.
random
.
rand
(
10
)
.
astype
(
theano
.
config
.
floatX
)
xv
=
n
p
.
random
.
rand
(
10
)
.
astype
(
theano
.
config
.
floatX
)
yv
=
n
p
.
random
.
rand
(
10
)
.
astype
(
theano
.
config
.
floatX
)
zv
=
n
p
.
random
.
rand
(
10
)
.
astype
(
theano
.
config
.
floatX
)
f
(
xv
,
yv
,
zv
)
doc/tutorial/using_gpu_solution_1.py
浏览文件 @
0784ab7b
...
...
@@ -7,13 +7,13 @@
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
theano
import
theano.tensor
as
tt
theano
.
config
.
floatX
=
'float32'
rng
=
n
umpy
.
random
rng
=
n
p
.
random
N
=
400
feats
=
784
...
...
@@ -25,7 +25,7 @@ training_steps = 10000
x
=
theano
.
shared
(
D
[
0
],
name
=
"x"
)
y
=
theano
.
shared
(
D
[
1
],
name
=
"y"
)
w
=
theano
.
shared
(
rng
.
randn
(
feats
)
.
astype
(
theano
.
config
.
floatX
),
name
=
"w"
)
b
=
theano
.
shared
(
n
umpy
.
asarray
(
0.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"b"
)
b
=
theano
.
shared
(
n
p
.
asarray
(
0.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"b"
)
x
.
tag
.
test_value
=
D
[
0
]
y
.
tag
.
test_value
=
D
[
1
]
#print "Initial model:"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论