Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7eb7f38e
提交
7eb7f38e
authored
5月 17, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SGrad, improvements to formula
上级
82d158a2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
46 行增加
和
1 行删除
+46
-1
formula.py
formula.py
+31
-0
tensor.py
tensor.py
+15
-1
没有找到文件。
formula.py
浏览文件 @
7eb7f38e
...
@@ -11,6 +11,23 @@ def _zip(*lists):
...
@@ -11,6 +11,23 @@ def _zip(*lists):
else
:
else
:
return
zip
(
*
lists
)
return
zip
(
*
lists
)
# x = ivector()
# y = ivector()
# e = x + y
# f = Formula(x = x, y = y, e = e)
# y = x + x
# g = Formula(x=x,y=y)
# x2 = x + x
# g = Formula(x=x, x2=x2)
class
Formula
(
utils
.
object2
):
class
Formula
(
utils
.
object2
):
def
__init__
(
self
,
symtable_d
=
{},
**
symtable_kwargs
):
def
__init__
(
self
,
symtable_d
=
{},
**
symtable_kwargs
):
...
@@ -257,11 +274,23 @@ class Formulas(utils.object2):
...
@@ -257,11 +274,23 @@ class Formulas(utils.object2):
# class Test(Formulas):
# class Test(Formulas):
# x = T.ivector()
# x = T.ivector()
# y = T.ivector()
# y = T.ivector()
# e = x + y + 21
# e = x + y + 21
# x = T.ivector()
# y = T.ivector()
# e = x + y + 21
# f1 = Formula(x = x, y = y, e = e)
# Test() -> f1.clone()
# f = Test()
# f = Test()
# print f
# print f
# print f.reassign(x = T.ivector())
# print f.reassign(x = T.ivector())
...
@@ -317,6 +346,8 @@ print unicode(g)
...
@@ -317,6 +346,8 @@ print unicode(g)
# lr = 0.01
# lr = 0.01
# def autoassociator_f(x, w, b, c):
# def autoassociator_f(x, w, b, c):
# reconstruction = sigmoid(T.dot(sigmoid(T.dot(x, w) + b), w.T) + c)
# reconstruction = sigmoid(T.dot(sigmoid(T.dot(x, w) + b), w.T) + c)
...
...
tensor.py
浏览文件 @
7eb7f38e
...
@@ -253,6 +253,11 @@ def tensor(*args, **kwargs):
...
@@ -253,6 +253,11 @@ def tensor(*args, **kwargs):
def
_multi
(
*
fns
):
def
_multi
(
*
fns
):
def
f2
(
f
,
names
):
def
f2
(
f
,
names
):
if
isinstance
(
names
,
int
):
if
names
==
1
:
return
f
()
else
:
return
[
f
()
for
i
in
xrange
(
names
)]
if
len
(
names
)
==
1
:
if
len
(
names
)
==
1
:
return
f
(
names
)
return
f
(
names
)
else
:
else
:
...
@@ -639,6 +644,7 @@ def transpose(x, **kwargs):
...
@@ -639,6 +644,7 @@ def transpose(x, **kwargs):
class
Subtensor
(
Op
):
class
Subtensor
(
Op
):
"""Return a subtensor view
"""Return a subtensor view
...
@@ -908,7 +914,7 @@ class Dot(Op):
...
@@ -908,7 +914,7 @@ class Dot(Op):
def
grad
(
self
,
(
x
,
y
),
(
gz
,)):
def
grad
(
self
,
(
x
,
y
),
(
gz
,)):
return
dot
(
gz
,
y
.
T
),
dot
(
x
.
T
,
gz
)
return
dot
(
gz
,
y
.
T
),
dot
(
x
.
T
,
gz
)
def
__str__
(
self
):
def
__str__
(
self
):
return
"
D
ot"
return
"
d
ot"
dot
=
Dot
()
dot
=
Dot
()
class
Gemm
(
Op
):
class
Gemm
(
Op
):
...
@@ -1136,6 +1142,14 @@ gemm = Gemm()
...
@@ -1136,6 +1142,14 @@ gemm = Gemm()
# Gradient
# Gradient
#########################
#########################
class
SGrad
(
gof
.
Op
):
def
make_node
(
self
,
cost
,
wrt
):
return
Apply
(
self
,
[
cost
,
wrt
],
[
wrt
.
type
()])
def
expand
(
self
,
r
):
cost
,
wrt
=
r
.
owner
.
inputs
return
grad
(
cost
,
wrt
)
sgrad
=
SGrad
()
def
grad
(
cost
,
wrt
,
g_cost
=
None
):
def
grad
(
cost
,
wrt
,
g_cost
=
None
):
"""
"""
@type cost: L{Result}
@type cost: L{Result}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论