Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
842da1f2
提交
842da1f2
authored
2月 26, 2016
作者:
Taesup (TS) Kim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix PEP8 in sandbox/*.py
上级
c51b2833
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
76 行增加
和
37 行删除
+76
-37
conv.py
theano/sandbox/conv.py
+2
-1
debug.py
theano/sandbox/debug.py
+28
-13
fourier.py
theano/sandbox/fourier.py
+11
-5
minimal.py
theano/sandbox/minimal.py
+10
-8
multinomial.py
theano/sandbox/multinomial.py
+10
-5
neighbourhoods.py
theano/sandbox/neighbourhoods.py
+12
-4
rng_mrg.py
theano/sandbox/rng_mrg.py
+0
-0
softsign.py
theano/sandbox/softsign.py
+1
-0
solve.py
theano/sandbox/solve.py
+2
-1
没有找到文件。
theano/sandbox/conv.py
浏览文件 @
842da1f2
from
__future__
import
print_function
import
sys
print
(
"DEPRECATION: theano.sandbox.conv no longer provides conv. They have been moved to theano.tensor.nnet.conv"
,
file
=
sys
.
stderr
)
print
(
"DEPRECATION: theano.sandbox.conv no longer provides conv. "
"They have been moved to theano.tensor.nnet.conv"
,
file
=
sys
.
stderr
)
from
theano.tensor.nnet.conv
import
*
theano/sandbox/debug.py
浏览文件 @
842da1f2
...
...
@@ -71,10 +71,15 @@ class DebugLinker(gof.WrapLinker):
r
.
type
.
filter
(
r
.
value
,
strict
=
True
)
except
TypeError
as
e
:
exc_type
,
exc_value
,
exc_trace
=
sys
.
exc_info
()
exc
=
DebugException
(
e
,
"The output
%
s was filled with data with the wrong type using linker "
\
(
"
%
s. This happened at step
%
i of the program."
%
(
r
,
linker
,
i
))
+
\
"For more info, inspect this exception's 'original_exception', 'debugger', "
\
"'output_at_fault', 'step', 'node', 'thunk' and 'linker' fields."
)
exc
=
DebugException
(
e
,
"The output
%
s was filled with data with the wrong "
"type using linker "
+
(
"
%
s. This happened at step
%
i of the program."
%
(
r
,
linker
,
i
))
+
"For more info, inspect this exception's "
"'original_exception', 'debugger', 'output_at_fault', "
"'step', 'node', 'thunk' and 'linker' fields."
)
exc
.
debugger
=
self
exc
.
original_exception
=
e
exc
.
output_at_fault
=
r
...
...
@@ -88,11 +93,18 @@ class DebugLinker(gof.WrapLinker):
thunk0
=
thunks
[
0
]
linker0
=
self
.
linkers
[
0
]
for
thunk
,
linker
in
zip
(
thunks
[
1
:],
self
.
linkers
[
1
:]):
for
o
,
output0
,
output
in
zip
(
node
.
outputs
,
thunk0
.
outputs
,
thunk
.
outputs
):
for
o
,
output0
,
output
in
zip
(
node
.
outputs
,
thunk0
.
outputs
,
thunk
.
outputs
):
if
not
self
.
compare_fn
(
output0
[
0
],
output
[
0
]):
exc
=
DebugException
((
"The variables from
%
s and
%
s for output
%
s are not the same. This happened at step
%
i."
%
(
linker0
,
linker
,
o
,
step
))
+
\
"For more info, inspect this exception's 'debugger', 'output', 'output_value1', 'output_value2', "
\
"'step', 'node', 'thunk1', 'thunk2', 'linker1' and 'linker2' fields."
)
exc
=
DebugException
(
(
"The variables from
%
s and
%
s for output
%
s are not "
"the same. This happened at step
%
i."
%
(
linker0
,
linker
,
o
,
step
))
+
"For more info, inspect this exception's 'debugger', "
"'output', 'output_value1', 'output_value2', 'step', "
"'node', 'thunk1', 'thunk2', 'linker1' "
"and 'linker2' fields."
)
exc
.
debugger
=
self
exc
.
output
=
o
exc
.
output_value1
=
output0
...
...
@@ -140,8 +152,12 @@ class DebugLinker(gof.WrapLinker):
exc_type
,
exc_value
,
exc_trace
=
sys
.
exc_info
()
if
isinstance
(
e
,
DebugException
):
raise
exc
=
DebugException
(
e
,
(
"An exception occurred while processing node
%
s at step
%
i of the program."
%
(
node
,
i
))
+
\
"For more info, inspect this exception's 'original_exception', 'debugger', 'step', 'node' and 'thunks' fields."
)
exc
=
DebugException
(
e
,
(
"An exception occurred while processing node
%
s at step
%
i "
"of the program."
%
(
node
,
i
))
+
"For more info, inspect this exception's 'original_exception',"
"'debugger', 'step', 'node' and 'thunks' fields."
)
exc
.
debugger
=
self
exc
.
original_exception
=
e
exc
.
step
=
i
...
...
@@ -169,7 +185,8 @@ def print_input_shapes(i, node, *thunks):
def
print_input_types
(
i
,
node
,
*
thunks
):
print
(
"input types:"
,
", "
.
join
(
str
(
type
(
input
.
value
))
for
input
in
node
.
inputs
))
print
(
"input types:"
,
", "
.
join
(
str
(
type
(
input
.
value
))
for
input
in
node
.
inputs
))
def
print_sep
(
i
,
node
,
*
thunks
):
...
...
@@ -192,5 +209,3 @@ def numpy_debug_linker(pre, post=None):
pre
,
post
,
compare_fn
=
numpy_compare
)
theano/sandbox/fourier.py
浏览文件 @
842da1f2
...
...
@@ -12,7 +12,7 @@ from theano.gof import Op, Apply, generic
class
GradTodo
(
Op
):
# TODO : need description for class
__props__
=
()
def
make_node
(
self
,
x
):
...
...
@@ -24,6 +24,7 @@ grad_todo = GradTodo()
class
FFT
(
Op
):
# TODO : need description for parameters
"""
Fast Fourier Transform.
...
...
@@ -44,7 +45,8 @@ class FFT(Op):
# don't return the plan object in the 'buf' output
half
=
False
"""Only return the first half (positive-valued) of the frequency components."""
"""Only return the first half (positive-valued) of the frequency
components."""
__props__
=
(
"half"
,
"inverse"
)
def
__init__
(
self
,
half
=
False
,
inverse
=
False
):
...
...
@@ -82,11 +84,13 @@ class FFT(Op):
M
,
N
=
fft
.
shape
if
axis
==
0
:
if
(
M
%
2
):
raise
ValueError
(
'halfFFT on odd-length vectors is undefined'
)
raise
ValueError
(
'halfFFT on odd-length vectors is undefined'
)
spectrogram
[
0
]
=
fft
[
0
:
M
/
2
,
:]
elif
axis
==
1
:
if
(
N
%
2
):
raise
ValueError
(
'halfFFT on odd-length vectors is undefined'
)
raise
ValueError
(
'halfFFT on odd-length vectors is undefined'
)
spectrogram
[
0
]
=
fft
[:,
0
:
N
/
2
]
else
:
raise
NotImplementedError
()
...
...
@@ -105,6 +109,7 @@ half_ifft = FFT(half=True, inverse=True)
def
dct_matrix
(
rows
,
cols
,
unitary
=
True
):
# TODO : need description for parameters
"""
Return a (rows x cols) matrix implementing a discrete cosine transform.
...
...
@@ -115,7 +120,8 @@ def dct_matrix(rows, cols, unitary=True):
col_range
=
numpy
.
arange
(
cols
)
scale
=
numpy
.
sqrt
(
2.0
/
cols
)
for
i
in
xrange
(
rows
):
rval
[
i
]
=
numpy
.
cos
(
i
*
(
col_range
*
2
+
1
)
/
(
2.0
*
cols
)
*
numpy
.
pi
)
*
scale
rval
[
i
]
=
numpy
.
cos
(
i
*
(
col_range
*
2
+
1
)
/
(
2.0
*
cols
)
*
numpy
.
pi
)
*
scale
if
unitary
:
rval
[
0
]
*=
numpy
.
sqrt
(
0.5
)
...
...
theano/sandbox/minimal.py
浏览文件 @
842da1f2
...
...
@@ -9,17 +9,19 @@ from theano.tests import unittest_tools as utt
class
Minimal
(
gof
.
Op
):
# TODO : need description for class
# if the Op has any attributes,
# consider using them in the eq function. If two Apply nodes have the same inputs and the
# ops compare equal... then they will be MERGED so they had better have computed the same
# thing!
# if the Op has any attributes, consider using them in the eq function.
# If two Apply nodes have the same inputs and the ops compare equal...
# then they will be MERGED so they had better have computed the same thing!
def
__init__
(
self
):
# If you put things here, think about whether they change the outputs computed by
# self.perform()
# - If they do, then you should take them into consideration in __eq__ and __hash__
# - If they do not, then you should not use them in __eq__ and __hash__
# If you put things here, think about whether they change the outputs
# computed by # self.perform()
# - If they do, then you should take them into consideration in
# __eq__ and __hash__
# - If they do not, then you should not use them in
# __eq__ and __hash__
super
(
Minimal
,
self
)
.
__init__
()
...
...
theano/sandbox/multinomial.py
浏览文件 @
842da1f2
...
...
@@ -16,6 +16,7 @@ if cuda_available:
class
MultinomialFromUniform
(
Op
):
# TODO : need description for parameter 'odtype'
"""
Converts samples from a uniform into sample from a multinomial.
...
...
@@ -197,7 +198,8 @@ class MultinomialFromUniform(Op):
class
MultinomialWOReplacementFromUniform
(
MultinomialFromUniform
):
"""
Converts samples from a uniform into sample (without replacement) from a multinomial.
Converts samples from a uniform into sample (without replacement) from a
multinomial.
"""
...
...
@@ -222,8 +224,8 @@ class MultinomialWOReplacementFromUniform(MultinomialFromUniform):
(
z
,)
=
outs
if
n_samples
>
pvals
.
shape
[
1
]:
raise
ValueError
(
"Cannot sample without replacement n samples
bigger
"
"than the size of the distribution."
)
raise
ValueError
(
"Cannot sample without replacement n samples "
"
bigger
than the size of the distribution."
)
if
unis
.
shape
[
0
]
!=
pvals
.
shape
[
0
]
*
n_samples
:
raise
ValueError
(
"unis.shape[0] != pvals.shape[0] * n_samples"
,
...
...
@@ -233,7 +235,8 @@ class MultinomialWOReplacementFromUniform(MultinomialFromUniform):
odtype
=
'int64'
else
:
odtype
=
self
.
odtype
if
z
[
0
]
is
None
or
not
numpy
.
all
(
z
[
0
]
.
shape
==
[
pvals
.
shape
[
0
],
n_samples
]):
if
(
z
[
0
]
is
None
or
not
numpy
.
all
(
z
[
0
]
.
shape
==
[
pvals
.
shape
[
0
],
n_samples
])):
z
[
0
]
=
-
1
*
numpy
.
ones
((
pvals
.
shape
[
0
],
n_samples
),
dtype
=
odtype
)
nb_multi
=
pvals
.
shape
[
0
]
...
...
@@ -249,7 +252,8 @@ class MultinomialWOReplacementFromUniform(MultinomialFromUniform):
cummul
+=
pvals
[
n
,
m
]
if
(
cummul
>
unis_n
):
z
[
0
][
n
,
c
]
=
m
# set to zero and re-normalize so that it's not selected again
# set to zero and re-normalize so that it's not
# selected again
pvals
[
n
,
m
]
=
0.
pvals
[
n
]
/=
pvals
[
n
]
.
sum
()
break
...
...
@@ -443,6 +447,7 @@ class GpuMultinomialFromUniform(MultinomialFromUniform, GpuOp):
@local_optimizer
([
MultinomialFromUniform
])
def
local_gpu_multinomial
(
node
):
# TODO : need description for function
if
type
(
node
.
op
)
is
MultinomialFromUniform
:
if
len
(
node
.
inputs
)
==
2
:
p
,
u
=
node
.
inputs
...
...
theano/sandbox/neighbourhoods.py
浏览文件 @
842da1f2
...
...
@@ -116,7 +116,8 @@ class NeighbourhoodsFromImages(Op):
return
dims
,
num_strides
# for inverse mode
# "output" here actually referes to the Op's input shape (but it's inverse mode)
# "output" here actually referes to the Op's input shape (but it's inverse
# mode)
def
in_shape
(
self
,
output_shape
):
out_dims
=
list
(
output_shape
[:
self
.
n_dims_before
])
num_strides
=
[]
...
...
@@ -168,9 +169,10 @@ class NeighbourhoodsFromImages(Op):
for
dim
in
self
.
dims_neighbourhoods
:
prod
*=
dim
if
x
.
shape
[
-
1
]
!=
prod
:
raise
ValueError
(
"Last dimension of neighbourhoods (
%
s) is not"
" the product of the neighbourhoods dimensions"
" (
%
s)"
%
(
str
(
x
.
shape
[
-
1
]),
str
(
prod
)))
raise
ValueError
(
"Last dimension of neighbourhoods (
%
s) is not"
" the product of the neighbourhoods dimensions"
" (
%
s)"
%
(
str
(
x
.
shape
[
-
1
]),
str
(
prod
)))
else
:
if
len
(
x
.
shape
)
!=
(
self
.
n_dims_before
+
len
(
self
.
dims_neighbourhoods
)):
...
...
@@ -195,6 +197,7 @@ class NeighbourhoodsFromImages(Op):
exec
(
self
.
code
)
def
make_py_code
(
self
):
# TODO : need description for method and return
code
=
self
.
_py_outerloops
()
for
i
in
xrange
(
len
(
self
.
strides
)):
code
+=
self
.
_py_innerloop
(
i
)
...
...
@@ -202,6 +205,7 @@ class NeighbourhoodsFromImages(Op):
return
code
,
builtins
.
compile
(
code
,
'<string>'
,
'exec'
)
def
_py_outerloops
(
self
):
# TODO : need description for method, parameter and return
code_before
=
""
for
dim_idx
in
xrange
(
self
.
n_dims_before
):
code_before
+=
(
'
\t
'
*
(
dim_idx
))
+
\
...
...
@@ -210,6 +214,7 @@ class NeighbourhoodsFromImages(Op):
return
code_before
def
_py_innerloop
(
self
,
inner_dim_no
):
# TODO : need description for method, parameter and return
base_indent
=
(
'
\t
'
*
(
self
.
n_dims_before
+
inner_dim_no
*
2
))
code_before
=
base_indent
+
\
"for stride_idx_
%
d in xrange(num_strides[
%
d]):
\n
"
%
\
...
...
@@ -229,10 +234,12 @@ class NeighbourhoodsFromImages(Op):
return
code_before
def
_py_flattened_idx
(
self
):
# TODO : need description for method and return
return
"+"
.
join
([
"neigh_strides[
%
d]*neigh_idx_
%
d"
%
(
i
,
i
)
for
i
in
xrange
(
len
(
self
.
strides
))])
def
_py_assignment
(
self
):
# TODO : need description for method and return
input_idx
=
""
.
join
([
"outer_idx_
%
d,"
%
(
i
,)
for
i
in
xrange
(
self
.
n_dims_before
)])
input_idx
+=
""
.
join
([
"dim_
%
d_offset+neigh_idx_
%
d,"
%
...
...
@@ -259,6 +266,7 @@ class NeighbourhoodsFromImages(Op):
class
ImagesFromNeighbourhoods
(
NeighbourhoodsFromImages
):
# TODO : need description for class, parameters
def
__init__
(
self
,
n_dims_before
,
dims_neighbourhoods
,
strides
=
None
,
ignore_border
=
False
):
NeighbourhoodsFromImages
.
__init__
(
self
,
n_dims_before
,
...
...
theano/sandbox/rng_mrg.py
浏览文件 @
842da1f2
差异被折叠。
点击展开。
theano/sandbox/softsign.py
浏览文件 @
842da1f2
...
...
@@ -4,6 +4,7 @@ import theano.tensor
class
ScalarSoftsign
(
theano
.
scalar
.
UnaryScalarOp
):
# TODO : need description for class
@staticmethod
def
static_impl
(
x
):
return
x
/
(
1.0
+
abs
(
x
))
...
...
theano/sandbox/solve.py
浏览文件 @
842da1f2
...
...
@@ -24,7 +24,8 @@ class Solve(gof.Op):
# sym_pos, lower, overwrite_a, overwrite_b
# TODO: Add C code that calls the underlying LAPACK routines
# and keeps a memory workspace from call to call as a non-default Op output
# and keeps a memory workspace from call to call as a non-default Op
# output
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论