Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b06dcd20
提交
b06dcd20
authored
3月 21, 2008
作者:
bergstrj@iro.umontreal.ca
浏览文件
操作
浏览文件
下载
差异文件
merged
上级
5afc5d9d
c7018dc2
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
21 行增加
和
6 行删除
+21
-6
.hgignore
.hgignore
+1
-0
_test_tensor.py
_test_tensor.py
+11
-4
gradient.py
gradient.py
+3
-0
tensor.py
tensor.py
+6
-2
没有找到文件。
.hgignore
浏览文件 @
b06dcd20
...
...
@@ -7,6 +7,7 @@ cutils_ext.cpp
html
*.o
pdf
pull.sh
*.pyc
*.so
*.sw?
_test_tensor.py
浏览文件 @
b06dcd20
...
...
@@ -463,6 +463,16 @@ class T_log2(unittest.TestCase):
def
test0
(
self
):
verify_grad
(
self
,
Log2
,
[
numpy
.
random
.
rand
(
3
,
1
)
+
0.0001
])
class
T_log
(
unittest
.
TestCase
):
def
test0
(
self
):
verify_grad
(
self
,
Log
,
[
numpy
.
random
.
rand
(
3
,
1
)
+
0.0001
])
def
test1
(
self
):
a
=
astensor
(
numpy
.
ones
(
2
))
b
=
astensor
(
numpy
.
ones
(
2
))
aa
=
numpy
.
asarray
([
0.5
,
4.0
])
bb
=
numpy
.
asarray
([
0.5
,
2.0
])
check_eq2
(
self
,
[
a
],
log
(
a
),
[
aa
],
numpy
.
log
(
numpy
.
asarray
(
aa
)))
class
T_pow
(
unittest
.
TestCase
):
def
setUp
(
self
):
numpy
.
random
.
seed
(
9999
)
...
...
@@ -493,10 +503,7 @@ class _testCase_matinv(unittest.TestCase):
# Sum of squared errors
ssdiff
=
sum
((
diff
**
2.0
))
# May be able to abbreviate this by assuming default parameter
# TODO: Test that default works
g_b
=
gradient
.
grad
(
ssdiff
,
b
,
astensor
(
numpy
.
ones
(
1
),
name
=
'g_cost'
))
#g_b = gradient.grad(ssdiff, b) # This should be the abbreviated version
g_b
=
gradient
.
grad
(
ssdiff
,
b
)
# compilation to function
# [a,b] are the inputs, [ssdiff,g_b] are the outputs
...
...
gradient.py
浏览文件 @
b06dcd20
...
...
@@ -81,7 +81,10 @@ def grad_sources_inputs(sources, graph_inputs):
op_grad
=
op
.
grad
(
input_arg
,
output_arg
)
if
op_grad
is
None
:
raise
ValueError
(
_msg_retNone
,
op
.
__class__
)
if
isinstance
(
op_grad
,
float
):
raise
TypeError
(
'wtf!!!!!!!!'
,
op
)
g_inputs
=
_pack_result
(
op_grad
)
assert
isinstance
(
g_inputs
,
(
list
,
tuple
))
if
len
(
g_inputs
)
!=
len
(
op
.
inputs
):
raise
ValueError
(
_msg_badlen
,
op
.
__class__
,
...
...
tensor.py
浏览文件 @
b06dcd20
...
...
@@ -107,7 +107,7 @@ def _assert_same_shapes(x, *rest):
shape
=
x
.
shape
for
other
in
rest
:
if
other
.
shape
!=
shape
:
raise
ValueError
(
_assert_same_shapes
.
E_shape
)
raise
ValueError
(
_assert_same_shapes
.
E_shape
,
shape
,
other
.
shape
)
_assert_same_shapes
.
E_shape
=
"The dimensions of the inputs do not match."
def
_assert_tensor_scalar
(
x
,
a
):
...
...
@@ -470,7 +470,11 @@ subtensor = _constructor(Subtensor)
# Elemwise #
class
AddElemwise
(
_Elemwise
):
def
impl
(
self
,
x
,
y
):
_assert_same_shapes
(
x
,
y
)
try
:
_assert_same_shapes
(
x
,
y
)
except
Exception
,
e
:
print
'------ ERROR HERE'
raise
return
x
+
y
def
grad
(
self
,
(
x
,
y
),
gz
):
return
gz
,
gz
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论