Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2a1a02d0
提交
2a1a02d0
authored
9月 22, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3416 from nouiz/bn_follow_up
BN follow up
上级
902c3972
9683d861
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
27 行增加
和
17 行删除
+27
-17
index.txt
doc/library/tensor/nnet/index.txt
+1
-0
profiling.py
theano/compile/profiling.py
+1
-1
gradient.py
theano/gradient.py
+6
-10
opt.py
theano/sandbox/cuda/opt.py
+1
-1
basic.py
theano/scalar/basic.py
+4
-1
basic.py
theano/tensor/basic.py
+4
-2
__init__.py
theano/tensor/nnet/__init__.py
+1
-0
bn.py
theano/tensor/nnet/bn.py
+4
-0
nnet.py
theano/tensor/nnet/nnet.py
+2
-0
opt.py
theano/tensor/opt.py
+3
-2
没有找到文件。
doc/library/tensor/nnet/index.txt
浏览文件 @
2a1a02d0
...
@@ -19,3 +19,4 @@ and ops which are particular to neural networks and deep learning.
...
@@ -19,3 +19,4 @@ and ops which are particular to neural networks and deep learning.
conv
conv
nnet
nnet
neighbours
neighbours
bn
theano/compile/profiling.py
浏览文件 @
2a1a02d0
...
@@ -697,7 +697,7 @@ class ProfileStats(object):
...
@@ -697,7 +697,7 @@ class ProfileStats(object):
print
(
'Time in all call to theano.grad()
%
es'
%
print
(
'Time in all call to theano.grad()
%
es'
%
theano
.
gradient
.
grad_time
,
file
=
file
)
theano
.
gradient
.
grad_time
,
file
=
file
)
total_time
=
time
.
time
()
-
theano_imported_time
total_time
=
time
.
time
()
-
theano_imported_time
print
(
'Time since theano import
%.3
fs'
%
(
total_time
))
print
(
'Time since theano import
%.3
fs'
%
(
total_time
)
,
file
=
file
)
def
summary_memory
(
self
,
file
,
N
=
None
):
def
summary_memory
(
self
,
file
,
N
=
None
):
fct_memory
=
{}
# fgraph->dict(node->[outputs size])
fct_memory
=
{}
# fgraph->dict(node->[outputs size])
...
...
theano/gradient.py
浏览文件 @
2a1a02d0
...
@@ -1612,15 +1612,10 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None,
...
@@ -1612,15 +1612,10 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None,
# We allow input downcast in function, because numeric_grad works in the
# We allow input downcast in function, because numeric_grad works in the
# most precise dtype used among the inputs, so we may need to cast some.
# most precise dtype used among the inputs, so we may need to cast some.
def
function
(
inputs
,
output
):
def
function
(
inputs
,
output
,
name
):
if
mode
is
None
:
f
=
compile
.
function
(
inputs
,
output
,
accept_inplace
=
True
,
allow_input_downcast
=
True
,
on_unused_input
=
'ignore'
)
else
:
f
=
compile
.
function
(
inputs
,
output
,
accept_inplace
=
True
,
f
=
compile
.
function
(
inputs
,
output
,
accept_inplace
=
True
,
allow_input_downcast
=
True
,
mode
=
mode
,
allow_input_downcast
=
True
,
mode
=
mode
,
on_unused_input
=
'ignore'
)
on_unused_input
=
'ignore'
,
name
=
name
)
return
f
return
f
tensor_pt
=
[
tensor_pt
=
[
...
@@ -1639,7 +1634,7 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None,
...
@@ -1639,7 +1634,7 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None,
# but this doesn't handle the case where not all the outputs are
# but this doesn't handle the case where not all the outputs are
# differentiable... so I leave this as TODO for now -JB.
# differentiable... so I leave this as TODO for now -JB.
o_fn
=
function
(
tensor_pt
,
o_output
)
o_fn
=
function
(
tensor_pt
,
o_output
,
name
=
'gradient.py fwd'
)
o_fn_out
=
o_fn
(
*
[
p
.
copy
()
for
p
in
pt
])
o_fn_out
=
o_fn
(
*
[
p
.
copy
()
for
p
in
pt
])
if
isinstance
(
o_fn_out
,
tuple
)
or
isinstance
(
o_fn_out
,
list
):
if
isinstance
(
o_fn_out
,
tuple
)
or
isinstance
(
o_fn_out
,
list
):
...
@@ -1663,12 +1658,13 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None,
...
@@ -1663,12 +1658,13 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None,
# This sum() is defined above, it's not the builtin sum.
# This sum() is defined above, it's not the builtin sum.
cost
=
theano
.
tensor
.
sum
(
t_r
*
o_output
)
cost
=
theano
.
tensor
.
sum
(
t_r
*
o_output
)
cost_fn
=
function
(
tensor_pt
,
cost
)
cost_fn
=
function
(
tensor_pt
,
cost
,
name
=
'gradient.py cost'
)
symbolic_grad
=
grad
(
cost
,
tensor_pt
,
symbolic_grad
=
grad
(
cost
,
tensor_pt
,
disconnected_inputs
=
'ignore'
)
disconnected_inputs
=
'ignore'
)
grad_fn
=
function
(
tensor_pt
,
symbolic_grad
)
grad_fn
=
function
(
tensor_pt
,
symbolic_grad
,
name
=
'gradient.py symbolic grad'
)
for
test_num
in
xrange
(
n_tests
):
for
test_num
in
xrange
(
n_tests
):
try
:
try
:
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
2a1a02d0
...
@@ -2146,7 +2146,7 @@ def local_gpualloc(node):
...
@@ -2146,7 +2146,7 @@ def local_gpualloc(node):
i
.
owner
.
op
in
[
host_from_gpu
,
tensor
.
alloc
]
i
.
owner
.
op
in
[
host_from_gpu
,
tensor
.
alloc
]
for
i
in
c
.
inputs
[
1
:]])
for
i
in
c
.
inputs
[
1
:]])
for
c
,
idx
in
node
.
outputs
[
0
]
.
clients
]):
for
c
,
idx
in
node
.
outputs
[
0
]
.
clients
]):
# if the client is
a subtensor with input
on gpu or alloc
# if the client is on gpu or alloc
replace
=
True
replace
=
True
if
replace
and
node
.
inputs
[
0
]
.
dtype
!=
'float32'
:
if
replace
and
node
.
inputs
[
0
]
.
dtype
!=
'float32'
:
replace
=
False
replace
=
False
...
...
theano/scalar/basic.py
浏览文件 @
2a1a02d0
...
@@ -3329,6 +3329,8 @@ class Composite(ScalarOp):
...
@@ -3329,6 +3329,8 @@ class Composite(ScalarOp):
Composite depends on all the Ops in its graph having C code.
Composite depends on all the Ops in its graph having C code.
"""
"""
init_param
=
(
'inputs'
,
'outputs'
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
...
@@ -3339,7 +3341,8 @@ class Composite(ScalarOp):
...
@@ -3339,7 +3341,8 @@ class Composite(ScalarOp):
This fct allow fix patch this.
This fct allow fix patch this.
"""
"""
out
=
self
.
__class__
(
self
.
inputs
,
self
.
outputs
)
d
=
dict
([(
k
,
getattr
(
self
,
k
))
for
k
in
self
.
init_param
])
out
=
self
.
__class__
(
**
d
)
if
name
:
if
name
:
out
.
name
=
name
out
.
name
=
name
else
:
else
:
...
...
theano/tensor/basic.py
浏览文件 @
2a1a02d0
...
@@ -3030,7 +3030,7 @@ def mean(input, axis=None, dtype=None, op=False, keepdims=False,
...
@@ -3030,7 +3030,7 @@ def mean(input, axis=None, dtype=None, op=False, keepdims=False,
if
dtype
==
'float16'
or
(
dtype
is
None
and
input
.
dtype
==
'float16'
):
if
dtype
==
'float16'
or
(
dtype
is
None
and
input
.
dtype
==
'float16'
):
s
=
cast
(
s
,
'float16'
)
s
=
cast
(
s
,
'float16'
)
s
.
name
=
'mean'
return
s
return
s
...
@@ -3075,7 +3075,9 @@ def var(input, axis=None, keepdims=False):
...
@@ -3075,7 +3075,9 @@ def var(input, axis=None, keepdims=False):
centered_input
=
input
-
mean_input
centered_input
=
input
-
mean_input
# return the mean sqr
# return the mean sqr
return
mean
((
centered_input
**
2
),
axis
,
keepdims
=
keepdims
)
v
=
mean
((
centered_input
**
2
),
axis
,
keepdims
=
keepdims
)
v
.
name
=
'var'
return
v
@constructor
@constructor
...
...
theano/tensor/nnet/__init__.py
浏览文件 @
2a1a02d0
...
@@ -6,3 +6,4 @@ from .ConvTransp3D import *
...
@@ -6,3 +6,4 @@ from .ConvTransp3D import *
from
.sigm
import
(
softplus
,
sigmoid
,
sigmoid_inplace
,
from
.sigm
import
(
softplus
,
sigmoid
,
sigmoid_inplace
,
scalar_sigmoid
,
ultra_fast_sigmoid
,
scalar_sigmoid
,
ultra_fast_sigmoid
,
hard_sigmoid
)
hard_sigmoid
)
from
.bn
import
batch_normalization
theano/tensor/nnet/bn.py
浏览文件 @
2a1a02d0
...
@@ -4,8 +4,10 @@ from theano.scalar import add, sub, true_div, mul
...
@@ -4,8 +4,10 @@ from theano.scalar import add, sub, true_div, mul
class
BNComposite
(
Composite
):
class
BNComposite
(
Composite
):
init_param
=
(
'dtype'
,)
def
__init__
(
self
,
dtype
):
def
__init__
(
self
,
dtype
):
self
.
dtype
=
dtype
x
=
theano
.
scalar
.
Scalar
(
dtype
=
dtype
)
.
make_variable
()
x
=
theano
.
scalar
.
Scalar
(
dtype
=
dtype
)
.
make_variable
()
mean
=
theano
.
scalar
.
Scalar
(
dtype
=
dtype
)
.
make_variable
()
mean
=
theano
.
scalar
.
Scalar
(
dtype
=
dtype
)
.
make_variable
()
std
=
theano
.
scalar
.
Scalar
(
dtype
=
dtype
)
.
make_variable
()
std
=
theano
.
scalar
.
Scalar
(
dtype
=
dtype
)
.
make_variable
()
...
@@ -33,6 +35,8 @@ def batch_normalization(inputs, gamma, beta, mean, std,
...
@@ -33,6 +35,8 @@ def batch_normalization(inputs, gamma, beta, mean, std,
to a set of activations.
to a set of activations.
Work also on GPU
Work also on GPU
.. versionadded:: 0.7.1
Parameters
Parameters
----------
----------
inputs : symbolic tensor
inputs : symbolic tensor
...
...
theano/tensor/nnet/nnet.py
浏览文件 @
2a1a02d0
...
@@ -2014,6 +2014,8 @@ def relu(x, alpha=0):
...
@@ -2014,6 +2014,8 @@ def relu(x, alpha=0):
"""
"""
Compute the element-wise rectified linear activation function.
Compute the element-wise rectified linear activation function.
.. versionadded:: 0.7.1
Parameters
Parameters
----------
----------
x : symbolic tensor
x : symbolic tensor
...
...
theano/tensor/opt.py
浏览文件 @
2a1a02d0
...
@@ -357,7 +357,7 @@ def inplace_elemwise_optimizer_op(OP):
...
@@ -357,7 +357,7 @@ def inplace_elemwise_optimizer_op(OP):
fgraph
.
validate
()
fgraph
.
validate
()
chk
=
fgraph
.
checkpoint
()
chk
=
fgraph
.
checkpoint
()
nb_change_no_validate
=
0
nb_change_no_validate
=
0
except
(
ValueError
,
TypeError
,
InconsistencyError
)
as
e
:
except
(
ValueError
,
InconsistencyError
)
as
e
:
if
check_each_change
!=
1
and
not
raised_warning
:
if
check_each_change
!=
1
and
not
raised_warning
:
print
((
"Some inplace optimization was not "
print
((
"Some inplace optimization was not "
"performed due to unexpected error:"
),
"performed due to unexpected error:"
),
...
@@ -2414,7 +2414,8 @@ def local_useless_subtensor(node):
...
@@ -2414,7 +2414,8 @@ def local_useless_subtensor(node):
return
[
node
.
inputs
[
0
]]
return
[
node
.
inputs
[
0
]]
@register_canonicalize
# fast_compile to allow opt subtensor(cast{float32}(make_vector))
@register_canonicalize
(
'fast_compile'
)
@gof.local_optimizer
([
Subtensor
])
@gof.local_optimizer
([
Subtensor
])
def
local_subtensor_lift
(
node
):
def
local_subtensor_lift
(
node
):
"""
"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论