Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
beb28c64
提交
beb28c64
authored
5月 28, 2012
作者:
Nicolas Bouchard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change directories
上级
ef088251
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
9 行增加
和
11 行删除
+9
-11
__init__.py
theano/extra_ops/__init__.py
+0
-2
extra_ops.py
theano/tensor/extra_ops.py
+8
-8
test_extra_ops.py
theano/tests/test_extra_ops.py
+1
-1
没有找到文件。
theano/extra_ops/__init__.py
deleted
100644 → 0
浏览文件 @
ef088251
from
extra_ops
import
(
DiffOp
,
diff
,
BinCountOp
,
bincount
)
theano/
extra_ops
/extra_ops.py
→
theano/
tensor
/extra_ops.py
浏览文件 @
beb28c64
import
theano
import
numpy
as
np
from
theano
import
tensor
as
T
import
basic
class
DiffOp
(
theano
.
Op
):
...
...
@@ -31,7 +31,7 @@ class DiffOp(theano.Op):
return
hash
(
type
(
self
))
^
hash
(
self
.
n
)
^
hash
(
self
.
axis
)
def
make_node
(
self
,
x
):
x
=
T
.
as_tensor_variable
(
x
)
x
=
basic
.
as_tensor_variable
(
x
)
return
theano
.
Apply
(
self
,
[
x
],
[
x
.
type
()])
def
perform
(
self
,
node
,
inputs
,
output_storage
):
...
...
@@ -49,8 +49,8 @@ class DiffOp(theano.Op):
z
=
outputs_gradients
[
0
]
def
_grad_helper
(
z
):
pre
=
T
.
concatenate
([[
0.
],
z
])
app
=
T
.
concatenate
([
z
,
[
0.
]])
pre
=
basic
.
concatenate
([[
0.
],
z
])
app
=
basic
.
concatenate
([
z
,
[
0.
]])
return
pre
-
app
for
k
in
range
(
self
.
n
):
...
...
@@ -120,7 +120,7 @@ class BinCountOp(theano.Op):
return
hash
(
type
(
self
))
^
hash
(
self
.
minlength
)
def
make_node
(
self
,
x
,
weights
):
x
=
T
.
as_tensor_variable
(
x
)
x
=
basic
.
as_tensor_variable
(
x
)
if
x
.
dtype
not
in
BinCountOp
.
compatible_type
:
raise
TypeError
(
"Inputs dtype must be an integer."
)
...
...
@@ -131,7 +131,7 @@ class BinCountOp(theano.Op):
weights
=
theano
.
gof
.
Constant
(
theano
.
gof
.
Generic
(),
None
)
out_type
=
x
.
type
()
else
:
weights
=
T
.
as_tensor_variable
(
weights
)
weights
=
basic
.
as_tensor_variable
(
weights
)
out_type
=
weights
.
type
()
if
weights
.
ndim
!=
1
:
raise
TypeError
(
"Weights cannot have a number of"
...
...
@@ -154,9 +154,9 @@ class BinCountOp(theano.Op):
def
infer_shape
(
self
,
node
,
ins_shapes
):
x
=
node
.
inputs
[
0
]
m
=
T
.
max
(
x
)
+
1
m
=
basic
.
max
(
x
)
+
1
if
self
.
minlength
!=
None
:
m
=
T
.
maximum
(
m
,
self
.
minlength
)
m
=
basic
.
maximum
(
m
,
self
.
minlength
)
return
[[
m
]]
def
__str__
(
self
):
...
...
theano/tests/test_extra_ops.py
浏览文件 @
beb28c64
...
...
@@ -3,7 +3,7 @@ import numpy as np
from
theano
import
tensor
as
T
from
theano.tests
import
unittest_tools
as
utt
from
theano.extra_ops
import
*
from
theano.
tensor.
extra_ops
import
*
class
TestBinCountOp
(
utt
.
InferShapeTester
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论