Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7611ad68
提交
7611ad68
authored
6月 26, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3046 from harlouci/flake8
Flake8 for files in sandbox
上级
c855e8d6
37be8c4b
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
36 行增加
和
30 行删除
+36
-30
fourier.py
theano/sandbox/fourier.py
+15
-12
minimal.py
theano/sandbox/minimal.py
+6
-3
multinomial.py
theano/sandbox/multinomial.py
+2
-3
neighbourhoods.py
theano/sandbox/neighbourhoods.py
+0
-0
neighbours.py
theano/sandbox/neighbours.py
+3
-1
solve.py
theano/sandbox/solve.py
+10
-5
test_flake8.py
theano/tests/test_flake8.py
+0
-6
没有找到文件。
theano/sandbox/fourier.py
浏览文件 @
7611ad68
"""Provides Ops for FFT and DCT.
"""
from
theano.gof
import
Op
,
Apply
,
generic
from
theano
import
tensor
import
numpy.fft
import
numpy
import
numpy.fft
from
six.moves
import
xrange
from
theano
import
tensor
from
theano.gof
import
Op
,
Apply
,
generic
class
GradTodo
(
Op
):
def
make_node
(
self
,
x
):
return
Apply
(
self
,
[
x
],
[
x
.
type
()])
def
perform
(
self
,
node
,
inputs
,
outputs
):
raise
NotImplementedError
(
'TODO'
)
grad_todo
=
GradTodo
()
...
...
@@ -45,8 +46,9 @@ class FFT(Op):
self
.
inverse
=
inverse
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
and
(
self
.
half
==
other
.
half
)
and
(
self
.
inverse
==
other
.
inverse
)
return
(
type
(
self
)
==
type
(
other
)
and
self
.
half
==
other
.
half
and
self
.
inverse
==
other
.
inverse
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
^
hash
(
self
.
half
)
^
9828743
^
(
self
.
inverse
)
...
...
@@ -77,21 +79,22 @@ class FFT(Op):
else
:
fft_fn
=
numpy
.
fft
.
fft
fft
=
fft_fn
(
frames
,
int
(
n
),
int
(
axis
))
fft
=
fft_fn
(
frames
,
int
(
n
),
int
(
axis
))
if
self
.
half
:
M
,
N
=
fft
.
shape
if
axis
==
0
:
if
(
M
%
2
):
raise
ValueError
(
'halfFFT on odd-length vectors is undefined'
)
spectrogram
[
0
]
=
fft
[
0
:
M
/
2
,
:]
spectrogram
[
0
]
=
fft
[
0
:
M
/
2
,
:]
elif
axis
==
1
:
if
(
N
%
2
):
raise
ValueError
(
'halfFFT on odd-length vectors is undefined'
)
spectrogram
[
0
]
=
fft
[:,
0
:
N
/
2
]
spectrogram
[
0
]
=
fft
[:,
0
:
N
/
2
]
else
:
raise
NotImplementedError
()
else
:
spectrogram
[
0
]
=
fft
def
grad
(
self
,
inp
,
out
):
frames
,
n
,
axis
=
inp
g_spectrogram
,
g_buf
=
out
...
...
@@ -112,9 +115,9 @@ def dct_matrix(rows, cols, unitary=True):
"""
rval
=
numpy
.
zeros
((
rows
,
cols
))
col_range
=
numpy
.
arange
(
cols
)
scale
=
numpy
.
sqrt
(
2.0
/
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
浏览文件 @
7611ad68
from
__future__
import
print_function
import
numpy
,
scipy
.
linalg
from
theano
import
gof
,
tensor
,
scalar
,
function
import
unittest
import
numpy
from
theano
import
gof
,
tensor
,
function
from
theano.tests
import
unittest_tools
as
utt
class
Minimal
(
gof
.
Op
):
...
...
@@ -49,7 +53,6 @@ minimal = Minimal()
# TODO: test dtype conversion
# TODO: test that invalid types are rejected by make_node
# TODO: test that each valid type for A and b works correctly
from
theano.tests
import
unittest_tools
as
utt
class
T_minimal
(
unittest
.
TestCase
):
...
...
theano/sandbox/multinomial.py
浏览文件 @
7611ad68
...
...
@@ -155,7 +155,6 @@ class MultinomialFromUniform(Op):
unis_n
=
unis
[
n
]
for
m
in
range
(
nb_outcomes
):
z_nm
=
z
[
0
][
n
,
m
]
cummul
+=
pvals
[
n
,
m
]
if
(
waiting
and
(
cummul
>
unis_n
)):
z
[
0
][
n
,
m
]
=
1
...
...
@@ -356,8 +355,8 @@ def local_gpu_multinomial(node):
return
[
host_from_gpu
(
gpu_op
(
*
[
gpu_from_host
(
i
)
for
i
in
node
.
inputs
]))
.
T
]
if
(
isinstance
(
node
.
op
,
theano
.
sandbox
.
cuda
.
GpuFromHost
)
and
node
.
inputs
[
0
]
.
owner
and
type
(
node
.
inputs
[
0
]
.
owner
.
op
)
is
MultinomialFromUniform
):
node
.
inputs
[
0
]
.
owner
and
type
(
node
.
inputs
[
0
]
.
owner
.
op
)
is
MultinomialFromUniform
):
multi
=
node
.
inputs
[
0
]
.
owner
p
,
u
=
multi
.
inputs
m
,
=
multi
.
outputs
...
...
theano/sandbox/neighbourhoods.py
浏览文件 @
7611ad68
差异被折叠。
点击展开。
theano/sandbox/neighbours.py
浏览文件 @
7611ad68
...
...
@@ -3,4 +3,6 @@ Neighbours was moved into theano.tensor.nnet.neighbours.
This file was created for compatibility.
"""
from
theano.tensor.nnet.neighbours
import
(
images2neibs
,
neibs2images
,
Images2Neibs
)
Images2Neibs
)
__all__
=
[
"images2neibs"
,
"neibs2images"
,
"Images2Neibs"
]
theano/sandbox/solve.py
浏览文件 @
7611ad68
from
__future__
import
print_function
import
numpy
,
scipy
.
linalg
from
theano
import
gof
,
tensor
,
scalar
import
unittest
import
sys
import
numpy
import
scipy.linalg
import
theano
from
theano
import
gof
,
tensor
,
scalar
from
theano.tests
import
unittest_tools
as
utt
class
Solve
(
gof
.
Op
):
...
...
@@ -32,7 +39,7 @@ class Solve(gof.Op):
raise
TypeError
(
"b must be a matrix or vector"
,
b_
.
type
)
odtype
=
scalar
.
upcast
(
A_
.
dtype
,
b_
.
dtype
)
otype
=
tensor
.
TensorType
(
broadcastable
=
b_
.
broadcastable
,
dtype
=
odtype
)
return
gof
.
Apply
(
op
=
self
,
inputs
=
[
A
,
B
],
outputs
=
[
otype
()])
return
gof
.
Apply
(
op
=
self
,
inputs
=
[
A
_
,
b_
],
outputs
=
[
otype
()])
def
perform
(
self
,
node
,
inp
,
out
):
A
,
b
=
inp
...
...
@@ -49,8 +56,6 @@ solve = Solve()
# TODO: test dtype conversion
# TODO: test that invalid types are rejected by make_node
# TODO: test that each valid type for A and b works correctly
from
theano.tests
import
unittest_tools
as
utt
class
T_solve
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
theano/tests/test_flake8.py
浏览文件 @
7611ad68
...
...
@@ -136,20 +136,14 @@ whitelist_flake8 = [
"sandbox/test_theano_object.py"
,
"sandbox/test_scan.py"
,
"sandbox/rng_mrg.py"
,
"sandbox/solve.py"
,
"sandbox/theano_object.py"
,
"sandbox/scan.py"
,
"sandbox/multinomial.py"
,
"sandbox/neighbourhoods.py"
,
"sandbox/fourier.py"
,
"sandbox/test_multinomial.py"
,
"sandbox/minimal.py"
,
"sandbox/test_rng_mrg.py"
,
"sandbox/test_neighbourhoods.py"
,
"sandbox/symbolic_module.py"
,
"sandbox/conv.py"
,
"sandbox/debug.py"
,
"sandbox/neighbours.py"
,
"sandbox/cuda/dnn.py"
,
"sandbox/cuda/var.py"
,
"sandbox/cuda/GpuConvGrad3D.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论