Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
115f6012
提交
115f6012
authored
11月 07, 2016
作者:
Frédéric Bastien
提交者:
GitHub
11月 07, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5179 from kvmanohar22/import_numpy
Import numpy
上级
205adfa4
d1a5f973
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
28 行增加
和
28 行删除
+28
-28
aa.py
benchmark/autoencoder/aa.py
+2
-2
aa_numpy.py
benchmark/autoencoder/aa_numpy.py
+12
-12
conv2d.py
benchmark/convolution/conv2d.py
+5
-5
opencv.py
benchmark/convolution/opencv.py
+4
-4
regression.py
benchmark/regression/regression.py
+5
-5
没有找到文件。
benchmark/autoencoder/aa.py
浏览文件 @
115f6012
#!/usr/bin/env python
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
import
sys
import
time
...
...
@@ -198,7 +198,7 @@ print(mod.pretty(mode=mode))
m
=
mod
.
make
(
mode
=
mode
)
neg
,
nout
,
nhid
,
niter
=
[
int
(
a
)
for
a
in
sys
.
argv
[
1
:]]
rng
=
n
umpy
.
random
.
RandomState
(
342
)
rng
=
n
p
.
random
.
RandomState
(
342
)
m
.
w
=
rng
.
rand
(
nout
,
nhid
)
m
.
a
=
rng
.
randn
(
nhid
)
*
0.0
m
.
b
=
rng
.
randn
(
nout
)
*
0.0
...
...
benchmark/autoencoder/aa_numpy.py
浏览文件 @
115f6012
#!/usr/bin/env python
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
as
N
import
numpy
as
np
import
sys
import
time
from
six.moves
import
xrange
...
...
@@ -10,7 +10,7 @@ from six.moves import xrange
neg
,
nout
,
nhid
,
niter
=
[
int
(
a
)
for
a
in
sys
.
argv
[
1
:]]
lr
=
0.01
rng
=
N
.
random
.
RandomState
(
342
)
rng
=
np
.
random
.
RandomState
(
342
)
w
=
rng
.
rand
(
nout
,
nhid
)
a
=
rng
.
randn
(
nhid
)
*
0.0
...
...
@@ -22,38 +22,38 @@ dot_time = 0.0
t
=
time
.
time
()
for
i
in
xrange
(
niter
):
tt
=
time
.
time
()
d
=
N
.
dot
(
x
,
w
)
d
=
np
.
dot
(
x
,
w
)
dot_time
+=
time
.
time
()
-
tt
hid
=
N
.
tanh
(
d
+
a
)
hid
=
np
.
tanh
(
d
+
a
)
tt
=
time
.
time
()
d
=
N
.
dot
(
hid
,
w
.
T
)
d
=
np
.
dot
(
hid
,
w
.
T
)
dot_time
+=
time
.
time
()
-
tt
out
=
N
.
tanh
(
d
+
b
)
out
=
np
.
tanh
(
d
+
b
)
g_out
=
out
-
x
err
=
0.5
*
N
.
sum
(
g_out
**
2
)
err
=
0.5
*
np
.
sum
(
g_out
**
2
)
g_hidwt
=
g_out
*
(
1.0
-
out
**
2
)
b
-=
lr
*
N
.
sum
(
g_hidwt
,
axis
=
0
)
b
-=
lr
*
np
.
sum
(
g_hidwt
,
axis
=
0
)
tt
=
time
.
time
()
g_hid
=
N
.
dot
(
g_hidwt
,
w
)
g_hid
=
np
.
dot
(
g_hidwt
,
w
)
dot_time
+=
time
.
time
()
-
tt
g_hidin
=
g_hid
*
(
1.0
-
hid
**
2
)
tt
=
time
.
time
()
d
=
N
.
dot
(
g_hidwt
.
T
,
hid
)
dd
=
N
.
dot
(
x
.
T
,
g_hidin
)
d
=
np
.
dot
(
g_hidwt
.
T
,
hid
)
dd
=
np
.
dot
(
x
.
T
,
g_hidin
)
dot_time
+=
time
.
time
()
-
tt
gw
=
(
d
+
dd
)
w
-=
lr
*
gw
a
-=
lr
*
N
.
sum
(
g_hidin
,
axis
=
0
)
a
-=
lr
*
np
.
sum
(
g_hidin
,
axis
=
0
)
total_time
=
time
.
time
()
-
t
print
(
'time: '
,
total_time
,
'err: '
,
err
)
...
...
benchmark/convolution/conv2d.py
浏览文件 @
115f6012
from
__future__
import
absolute_import
,
print_function
,
division
import
sys
,
timeit
,
time
import
numpy
import
numpy
as
np
import
theano
,
theano
.
tensor
.
signal
.
conv
try
:
...
...
@@ -17,16 +17,16 @@ if len(sys.argv)>6:
setup
=
"""
import sys, timeit, time
import numpy
import numpy
as np
import theano, theano.tensor.signal.conv
img_shape = int(sys.argv[1]), int(sys.argv[2])
ker_shape = int(sys.argv[3]), int(sys.argv[4])
dtype = sys.argv[5]
img = theano.shared(n
umpy
.ones(img_shape, dtype=dtype))
ker = theano.shared(n
umpy
.ones(ker_shape, dtype=dtype))
out = theano.shared(n
umpy
.ones((2,2,2), dtype=dtype))
img = theano.shared(n
p
.ones(img_shape, dtype=dtype))
ker = theano.shared(n
p
.ones(ker_shape, dtype=dtype))
out = theano.shared(n
p
.ones((2,2,2), dtype=dtype))
"""
T
=
timeit
.
Timer
(
"f()"
,
...
...
benchmark/convolution/opencv.py
浏览文件 @
115f6012
from
__future__
import
absolute_import
,
print_function
,
division
import
sys
,
timeit
import
numpy
import
numpy
as
np
import
scikits.image.opencv
try
:
...
...
@@ -16,13 +16,13 @@ if len(sys.argv)>6:
nb_call
=
int
(
sys
.
argv
[
6
])
T
=
timeit
.
Timer
(
"f()"
,
"""
import scikits.image.opencv, sys, numpy
import scikits.image.opencv, sys, numpy
as np
img_shape = int(sys.argv[1]), int(sys.argv[2])
ker_shape = int(sys.argv[3]), int(sys.argv[4])
dtype = sys.argv[5]
img = n
umpy
.ones(img_shape, dtype=dtype)
ker = n
umpy
.ones(ker_shape, dtype=dtype)
img = n
p
.ones(img_shape, dtype=dtype)
ker = n
p
.ones(ker_shape, dtype=dtype)
def f():
scikits.image.opencv.cvFilter2D(img, ker)
...
...
benchmark/regression/regression.py
浏览文件 @
115f6012
from
__future__
import
absolute_import
,
print_function
,
division
import
theano
import
numpy
as
N
import
numpy
as
np
from
theano
import
tensor
as
T
from
theano.tensor
import
nnet
as
NN
from
six.moves
import
xrange
...
...
@@ -50,9 +50,9 @@ class RegressionLayer(M.Module):
if
input_size
and
target_size
:
# initialize w and b in a special way using input_size and target_size
sz
=
(
input_size
,
target_size
)
rng
=
N
.
random
.
RandomState
(
seed
)
rng
=
np
.
random
.
RandomState
(
seed
)
obj
.
w
=
rng
.
uniform
(
size
=
sz
,
low
=
-
0.5
,
high
=
0.5
)
obj
.
b
=
N
.
zeros
(
target_size
)
obj
.
b
=
np
.
zeros
(
target_size
)
obj
.
stepsize
=
0.01
# here we call the default_initialize method, which takes all the name: value
# pairs in init and sets the property with that name to the provided value
...
...
@@ -93,8 +93,8 @@ def test_module_advanced_example():
profmode
=
PrintEverythingMode
(
theano
.
gof
.
OpWiseCLinker
(),
'fast_run'
)
data_x
=
N
.
random
.
randn
(
4
,
10
)
data_y
=
[
[
int
(
x
)]
for
x
in
(
N
.
random
.
randn
(
4
)
>
0
)]
data_x
=
np
.
random
.
randn
(
4
,
10
)
data_y
=
[
[
int
(
x
)]
for
x
in
(
np
.
random
.
randn
(
4
)
>
0
)]
model
=
SpecifiedRegressionLayer
(
regularize
=
False
)
.
make
(
input_size
=
10
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论