Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
dd4f2597
提交
dd4f2597
authored
2月 04, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Whitespace and tabs
上级
5c28147a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
18 行删除
+18
-18
test_nnet.py
theano/sandbox/cuda/tests/test_nnet.py
+10
-10
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+8
-8
没有找到文件。
theano/sandbox/cuda/tests/test_nnet.py
浏览文件 @
dd4f2597
...
@@ -46,7 +46,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
...
@@ -46,7 +46,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
yy
=
numpy
.
ones
((
batch_size
,),
dtype
=
'int32'
)
yy
=
numpy
.
ones
((
batch_size
,),
dtype
=
'int32'
)
b_values
=
numpy
.
zeros
((
n_out
,),
dtype
=
'float32'
)
b_values
=
numpy
.
zeros
((
n_out
,),
dtype
=
'float32'
)
W_values
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
n_in
,
n_out
),
dtype
=
'float32'
)
W_values
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
n_in
,
n_out
),
dtype
=
'float32'
)
dot_value
=
numpy
.
asarray
(
numpy
.
dot
(
xx
,
W_values
),
dtype
=
'float32'
)
dot_value
=
numpy
.
asarray
(
numpy
.
dot
(
xx
,
W_values
),
dtype
=
'float32'
)
p_y_given_x
=
T
.
nnet
.
softmax
(
dot_result
+
b
)
p_y_given_x
=
T
.
nnet
.
softmax
(
dot_result
+
b
)
...
@@ -59,7 +59,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
...
@@ -59,7 +59,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
mode
=
mode_with_gpu
)
mode
=
mode_with_gpu
)
#theano.printing.debugprint(classify)
#theano.printing.debugprint(classify)
#theano.printing.debugprint(classify_gpu)
#theano.printing.debugprint(classify_gpu)
assert
any
([
isinstance
(
node
.
op
,
T
.
nnet
.
CrossentropySoftmaxArgmax1HotWithBias
)
for
node
in
classify
.
maker
.
env
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
T
.
nnet
.
CrossentropySoftmaxArgmax1HotWithBias
)
for
node
in
classify
.
maker
.
env
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
cuda
.
nnet
.
GpuCrossentropySoftmaxArgmax1HotWithBias
)
for
node
in
classify_gpu
.
maker
.
env
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
cuda
.
nnet
.
GpuCrossentropySoftmaxArgmax1HotWithBias
)
for
node
in
classify_gpu
.
maker
.
env
.
toposort
()])
...
@@ -82,7 +82,7 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
...
@@ -82,7 +82,7 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
n_in
=
1000
n_in
=
1000
batch_size
=
4097
batch_size
=
4097
n_out
=
1250
n_out
=
1250
softmax_output_value
=
numpy
.
random
.
rand
(
batch_size
,
n_out
)
.
astype
(
'float32'
)
softmax_output_value
=
numpy
.
random
.
rand
(
batch_size
,
n_out
)
.
astype
(
'float32'
)
softmax_output
=
T
.
fmatrix
()
softmax_output
=
T
.
fmatrix
()
...
@@ -91,20 +91,20 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
...
@@ -91,20 +91,20 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
numpy
.
asarray
(
numpy
.
random
.
rand
(
batch_size
),
dtype
=
'float32'
),
numpy
.
asarray
(
numpy
.
random
.
rand
(
batch_size
),
dtype
=
'float32'
),
softmax_output
,
softmax_output
,
numpy
.
random
.
randint
(
low
=
0
,
high
=
5
,
size
=
batch_size
))
numpy
.
random
.
randint
(
low
=
0
,
high
=
5
,
size
=
batch_size
))
cpu_f
=
theano
.
function
([
softmax_output
],
op
,
mode
=
mode_without_gpu
)
cpu_f
=
theano
.
function
([
softmax_output
],
op
,
mode
=
mode_without_gpu
)
gpu_f
=
theano
.
function
([
softmax_output
],
op
,
mode
=
mode_with_gpu
)
gpu_f
=
theano
.
function
([
softmax_output
],
op
,
mode
=
mode_with_gpu
)
#theano.printing.debugprint(cpu_f)
#theano.printing.debugprint(cpu_f)
#theano.printing.debugprint(gpu_f)
#theano.printing.debugprint(gpu_f)
assert
any
([
isinstance
(
node
.
op
,
T
.
nnet
.
CrossentropySoftmax1HotWithBiasDx
)
for
node
in
cpu_f
.
maker
.
env
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
T
.
nnet
.
CrossentropySoftmax1HotWithBiasDx
)
for
node
in
cpu_f
.
maker
.
env
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
cuda
.
nnet
.
GpuCrossentropySoftmax1HotWithBiasDx
)
for
node
in
gpu_f
.
maker
.
env
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
cuda
.
nnet
.
GpuCrossentropySoftmax1HotWithBiasDx
)
for
node
in
gpu_f
.
maker
.
env
.
toposort
()])
cpu_out
=
cpu_f
(
softmax_output_value
)
cpu_out
=
cpu_f
(
softmax_output_value
)
gpu_out
=
gpu_f
(
softmax_output_value
)
gpu_out
=
gpu_f
(
softmax_output_value
)
assert
numpy
.
allclose
(
cpu_out
,
gpu_out
,
rtol
=
9e-4
)
assert
numpy
.
allclose
(
cpu_out
,
gpu_out
,
rtol
=
9e-4
)
def
test_softmax_with_bias
():
def
test_softmax_with_bias
():
"""
"""
This is basic test for GpuSoftmaxWithBias
This is basic test for GpuSoftmaxWithBias
...
@@ -125,7 +125,7 @@ def test_softmax_with_bias():
...
@@ -125,7 +125,7 @@ def test_softmax_with_bias():
f_gpu
=
theano
.
function
([
x
],
z
,
mode
=
mode_with_gpu
)
f_gpu
=
theano
.
function
([
x
],
z
,
mode
=
mode_with_gpu
)
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
nnet
.
softmax_with_bias
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
nnet
.
softmax_with_bias
assert
isinstance
(
f_gpu
.
maker
.
env
.
toposort
()[
-
2
]
.
op
,
cuda
.
nnet
.
GpuSoftmaxWithBias
)
assert
isinstance
(
f_gpu
.
maker
.
env
.
toposort
()[
-
2
]
.
op
,
cuda
.
nnet
.
GpuSoftmaxWithBias
)
out
=
f
(
data
)
out
=
f
(
data
)
gout
=
f_gpu
(
data
)
gout
=
f_gpu
(
data
)
assert
numpy
.
allclose
(
out
,
gout
),
numpy
.
absolute
(
out
-
gout
)
assert
numpy
.
allclose
(
out
,
gout
),
numpy
.
absolute
(
out
-
gout
)
...
@@ -150,7 +150,7 @@ def test_softmax():
...
@@ -150,7 +150,7 @@ def test_softmax():
f_gpu
=
theano
.
function
([
x
],
z
,
mode
=
mode_with_gpu
)
f_gpu
=
theano
.
function
([
x
],
z
,
mode
=
mode_with_gpu
)
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
nnet
.
softmax
assert
f
.
maker
.
env
.
toposort
()[
-
1
]
.
op
==
T
.
nnet
.
softmax
assert
isinstance
(
f_gpu
.
maker
.
env
.
toposort
()[
-
2
]
.
op
,
cuda
.
nnet
.
GpuSoftmax
)
assert
isinstance
(
f_gpu
.
maker
.
env
.
toposort
()[
-
2
]
.
op
,
cuda
.
nnet
.
GpuSoftmax
)
out
=
f
(
data
)
out
=
f
(
data
)
gout
=
f_gpu
(
data
)
gout
=
f_gpu
(
data
)
assert
numpy
.
allclose
(
out
,
gout
),
numpy
.
absolute
(
out
-
gout
)
assert
numpy
.
allclose
(
out
,
gout
),
numpy
.
absolute
(
out
-
gout
)
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
dd4f2597
...
@@ -12,15 +12,15 @@ from theano.gof.python25 import all
...
@@ -12,15 +12,15 @@ from theano.gof.python25 import all
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
from
theano
import
printing
,
pprint
from
theano
import
printing
,
pprint
from
theano.tensor.nnet
import
(
categorical_crossentropy
,
from
theano.tensor.nnet
import
(
categorical_crossentropy
,
crossentropy_categorical_1hot
,
crossentropy_categorical_1hot
,
crossentropy_softmax_1hot
,
crossentropy_softmax_1hot
,
crossentropy_softmax_1hot_with_bias
,
crossentropy_softmax_1hot_with_bias
,
crossentropy_softmax_1hot_with_bias_dx
,
crossentropy_softmax_1hot_with_bias_dx
,
crossentropy_softmax_argmax_1hot_with_bias
,
crossentropy_softmax_argmax_1hot_with_bias
,
sigmoid
,
softplus
,
sigmoid
,
softplus
,
Softmax
,
softmax
,
SoftmaxWithBias
,
softmax_grad
,
Softmax
,
softmax
,
SoftmaxWithBias
,
softmax_grad
,
softmax_with_bias
,
softmax_with_bias
,
Prepend_scalar_constant_to_each_row
,
Prepend_scalar_constant_to_each_row
,
Prepend_scalar_to_each_row
)
Prepend_scalar_to_each_row
)
class
T_sigmoid
(
unittest
.
TestCase
):
class
T_sigmoid
(
unittest
.
TestCase
):
...
@@ -106,7 +106,7 @@ class T_SoftmaxWithBias(unittest.TestCase):
...
@@ -106,7 +106,7 @@ class T_SoftmaxWithBias(unittest.TestCase):
vbias
=
theano
.
shared
(
value
=
0.1
,
name
=
'vbias'
)
#0.01
vbias
=
theano
.
shared
(
value
=
0.1
,
name
=
'vbias'
)
#0.01
hid
=
T
.
vector
(
'hid'
)
hid
=
T
.
vector
(
'hid'
)
f
=
theano
.
function
([
hid
],
f
=
theano
.
function
([
hid
],
T
.
nnet
.
softmax
(
T
.
dot
(
hid
,
W
.
T
)
+
vbias
))
T
.
nnet
.
softmax
(
T
.
dot
(
hid
,
W
.
T
)
+
vbias
))
ops
=
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()]
ops
=
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()]
assert
softmax_with_bias
not
in
ops
assert
softmax_with_bias
not
in
ops
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论