Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
159a0597
提交
159a0597
authored
1月 16, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bla
上级
04ab186e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
11 行删除
+20
-11
core.py
core.py
+14
-11
test.py
test.py
+6
-0
没有找到文件。
core.py
浏览文件 @
159a0597
...
@@ -145,13 +145,16 @@ class omega_op(gof.PythonOp):
...
@@ -145,13 +145,16 @@ class omega_op(gof.PythonOp):
return
UNDEFINED
return
UNDEFINED
def
scalar_switch
(
normal_f
,
scalar_f
,
scalar_f_reverse
):
def
scalar_switch
(
normal_f
,
scalar_f
,
scalar_f_reverse
=
None
):
def
f
(
x
,
y
):
def
f
(
x
,
y
):
x
,
y
=
wrap
(
x
),
wrap
(
y
)
x
,
y
=
wrap
(
x
),
wrap
(
y
)
if
x
.
constant
and
not
x
.
data
.
shape
:
return
scalar_f_reverse
(
y
,
x
)
if
y
.
constant
and
not
y
.
data
.
shape
:
if
y
.
constant
and
not
y
.
data
.
shape
:
return
scalar_f
(
x
,
y
)
return
scalar_f
(
x
,
y
)
if
x
.
constant
and
not
x
.
data
.
shape
:
if
scalar_f_reverse
:
return
scalar_f_reverse
(
y
,
x
)
else
:
raise
TypeError
(
"You cannot do this operation on a scalar."
)
return
normal_f
(
x
,
y
)
return
normal_f
(
x
,
y
)
return
f
return
f
...
@@ -286,8 +289,8 @@ def sub_scalar_l(x, a):
...
@@ -286,8 +289,8 @@ def sub_scalar_l(x, a):
def
isub_scalar_r
(
x
,
a
):
def
isub_scalar_r
(
x
,
a
):
return
iadd_scalar
(
x
,
-
a
)
return
iadd_scalar
(
x
,
-
a
)
def
isub_scalar_l
(
x
,
a
):
#
def isub_scalar_l(x, a):
return
iadd_scalar
(
-
x
,
a
)
# return iadd_scalar(ineg(x)
, a)
## Element-wise multiplication ##
## Element-wise multiplication ##
...
@@ -363,8 +366,8 @@ def div_scalar_l(x, a):
...
@@ -363,8 +366,8 @@ def div_scalar_l(x, a):
def
idiv_scalar_r
(
x
,
a
):
def
idiv_scalar_r
(
x
,
a
):
return
iscale
(
x
,
inv_elemwise
(
a
))
return
iscale
(
x
,
inv_elemwise
(
a
))
def
idiv_scalar_l
(
x
,
a
):
#
def idiv_scalar_l(x, a):
return
iscale
(
inv_elemwise
(
x
),
a
)
#
return iscale(inv_elemwise(x), a)
...
@@ -485,16 +488,16 @@ class sum(omega_op):
...
@@ -485,16 +488,16 @@ class sum(omega_op):
add
=
scalar_switch
(
add_elemwise
,
add_scalar
,
add_scalar
)
add
=
scalar_switch
(
add_elemwise
,
add_scalar
,
add_scalar
)
iadd
=
scalar_switch
(
iadd_elemwise
,
iadd_scalar
,
iadd_scalar
)
iadd
=
scalar_switch
(
iadd_elemwise
,
iadd_scalar
)
sub
=
scalar_switch
(
sub_elemwise
,
sub_scalar_r
,
sub_scalar_l
)
sub
=
scalar_switch
(
sub_elemwise
,
sub_scalar_r
,
sub_scalar_l
)
isub
=
scalar_switch
(
isub_elemwise
,
isub_scalar_r
,
isub_scalar_l
)
isub
=
scalar_switch
(
isub_elemwise
,
isub_scalar_r
)
mul
=
scalar_switch
(
mul_elemwise
,
scale
,
scale
)
mul
=
scalar_switch
(
mul_elemwise
,
scale
,
scale
)
imul
=
scalar_switch
(
imul_elemwise
,
iscale
,
iscale
)
imul
=
scalar_switch
(
imul_elemwise
,
iscale
)
div
=
scalar_switch
(
div_elemwise
,
div_scalar_r
,
div_scalar_l
)
div
=
scalar_switch
(
div_elemwise
,
div_scalar_r
,
div_scalar_l
)
idiv
=
scalar_switch
(
idiv_elemwise
,
idiv_scalar_r
,
idiv_scalar_l
)
idiv
=
scalar_switch
(
idiv_elemwise
,
idiv_scalar_r
)
pow
=
scalar_switch
(
pow_elemwise
,
pow_scalar_r
,
pow_scalar_l
)
pow
=
scalar_switch
(
pow_elemwise
,
pow_scalar_r
,
pow_scalar_l
)
ipow
=
scalar_switch
(
ipow_elemwise
,
ipow_scalar_r
,
ipow_scalar_l
)
ipow
=
scalar_switch
(
ipow_elemwise
,
ipow_scalar_r
,
ipow_scalar_l
)
...
...
test.py
浏览文件 @
159a0597
...
@@ -179,6 +179,9 @@ core.pop_mode()
...
@@ -179,6 +179,9 @@ core.pop_mode()
# @omega_compile
# @omega_compile
def
autoassociator
(
w
,
x
):
def
autoassociator
(
w
,
x
):
forward
=
sigmoid
(
core
.
dot
(
sigmoid
(
core
.
dot
(
x
,
w
)),
w
.
T
))
forward
=
sigmoid
(
core
.
dot
(
sigmoid
(
core
.
dot
(
x
,
w
)),
w
.
T
))
rec_error
=
core
.
sum
(
core
.
sqr
(
x
-
forward
))
rec_error
=
core
.
sum
(
core
.
sqr
(
x
-
forward
))
...
@@ -249,3 +252,6 @@ x += y.T
...
@@ -249,3 +252,6 @@ x += y.T
print
x
print
x
core
.
pop_mode
()
core
.
pop_mode
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论