Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b8374e28
提交
b8374e28
authored
7月 18, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3157 from harlouci/props_tests
Props tests
上级
9dc0dc8e
4ae1e1a8
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
28 行增加
和
56 行删除
+28
-56
cop.txt
doc/extending/cop.txt
+2
-0
fibby.txt
doc/extending/fibby.txt
+1
-6
op.txt
doc/extending/op.txt
+2
-6
gpu_data_convert.txt
doc/tutorial/gpu_data_convert.txt
+1
-6
using_gpu.txt
doc/tutorial/using_gpu.txt
+1
-7
test_gradient.py
theano/tests/test_gradient.py
+9
-0
test_rop.py
theano/tests/test_rop.py
+1
-5
test_tutorial.py
theano/tests/test_tutorial.py
+11
-26
没有找到文件。
doc/extending/cop.txt
浏览文件 @
b8374e28
...
@@ -308,6 +308,8 @@ version that it produces in the code I gave above.
...
@@ -308,6 +308,8 @@ version that it produces in the code I gave above.
class BinaryDoubleOp(gof.Op):
class BinaryDoubleOp(gof.Op):
__props__ = ("name", "fn", "ccode")
def __init__(self, name, fn, ccode):
def __init__(self, name, fn, ccode):
self.name = name
self.name = name
self.fn = fn
self.fn = fn
...
...
doc/extending/fibby.txt
浏览文件 @
b8374e28
...
@@ -35,12 +35,7 @@ you should check the strides and alignment.
...
@@ -35,12 +35,7 @@ you should check the strides and alignment.
"""
"""
An arbitrarily generalized Fibbonacci sequence
An arbitrarily generalized Fibbonacci sequence
"""
"""
__props__ = ()
def __eq__(self, other):
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def make_node(self, x):
def make_node(self, x):
x_ = tensor.as_tensor_variable(x)
x_ = tensor.as_tensor_variable(x)
...
...
doc/extending/op.txt
浏览文件 @
b8374e28
...
@@ -682,16 +682,12 @@ arithmetic operators:
...
@@ -682,16 +682,12 @@ arithmetic operators:
class BinaryDoubleOp(gof.Op):
class BinaryDoubleOp(gof.Op):
__props__ = ("name", "fn")
def __init__(self, name, fn):
def __init__(self, name, fn):
self.name = name
self.name = name
self.fn = fn
self.fn = fn
def __eq__(self, other):
return type(self) == type(other) and (self.name == other.name) and (self.fn == other.fn)
def __hash__(self):
return hash(type(self)) ^ hash(self.name) ^ hash(self.fn)
def make_node(self, x, y):
def make_node(self, x, y):
if isinstance(x, (int, float)):
if isinstance(x, (int, float)):
x = gof.Constant(double, x)
x = gof.Constant(double, x)
...
...
doc/tutorial/gpu_data_convert.txt
浏览文件 @
b8374e28
...
@@ -86,12 +86,7 @@ You can use a GPU function compiled with PyCUDA in a Theano op:
...
@@ -86,12 +86,7 @@ You can use a GPU function compiled with PyCUDA in a Theano op:
import theano.sandbox.cuda as cuda
import theano.sandbox.cuda as cuda
class PyCUDADoubleOp(theano.Op):
class PyCUDADoubleOp(theano.Op):
def __eq__(self, other):
__props__ = ()
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def __str__(self):
return self.__class__.__name__
def make_node(self, inp):
def make_node(self, inp):
inp = cuda.basic_ops.gpu_contiguous(
inp = cuda.basic_ops.gpu_contiguous(
cuda.basic_ops.as_cuda_ndarray_variable(inp))
cuda.basic_ops.as_cuda_ndarray_variable(inp))
...
...
doc/tutorial/using_gpu.txt
浏览文件 @
b8374e28
...
@@ -688,14 +688,8 @@ Modify and execute to work for a matrix of shape (20, 10).
...
@@ -688,14 +688,8 @@ Modify and execute to work for a matrix of shape (20, 10).
import theano.sandbox.cuda as cuda
import theano.sandbox.cuda as cuda
class PyCUDADoubleOp(theano.Op):
class PyCUDADoubleOp(theano.Op):
def __eq__(self, other):
return type(self) == type(other)
def __hash__(self):
__props__ = ()
return hash(type(self))
def __str__(self):
return self.__class__.__name__
def make_node(self, inp):
def make_node(self, inp):
inp = cuda.basic_ops.gpu_contiguous(
inp = cuda.basic_ops.gpu_contiguous(
...
...
theano/tests/test_gradient.py
浏览文件 @
b8374e28
...
@@ -36,6 +36,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -36,6 +36,7 @@ class testgrad_sources_inputs(unittest.TestCase):
def
test_retNone1
(
self
):
def
test_retNone1
(
self
):
"""Test that it is not ok to return None from op.grad()"""
"""Test that it is not ok to return None from op.grad()"""
class
retNone
(
gof
.
op
.
Op
):
class
retNone
(
gof
.
op
.
Op
):
__props__
=
()
def
make_node
(
self
):
def
make_node
(
self
):
inputs
=
[
theano
.
tensor
.
vector
()]
inputs
=
[
theano
.
tensor
.
vector
()]
outputs
=
[
theano
.
tensor
.
vector
()]
outputs
=
[
theano
.
tensor
.
vector
()]
...
@@ -52,6 +53,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -52,6 +53,7 @@ class testgrad_sources_inputs(unittest.TestCase):
"""Test that it is not ok to return the wrong number of gradient terms
"""Test that it is not ok to return the wrong number of gradient terms
"""
"""
class
retOne
(
gof
.
op
.
Op
):
class
retOne
(
gof
.
op
.
Op
):
__props__
=
()
def
make_node
(
self
,
*
inputs
):
def
make_node
(
self
,
*
inputs
):
outputs
=
[
theano
.
tensor
.
vector
()]
outputs
=
[
theano
.
tensor
.
vector
()]
return
gof
.
Apply
(
self
,
inputs
,
outputs
)
return
gof
.
Apply
(
self
,
inputs
,
outputs
)
...
@@ -72,6 +74,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -72,6 +74,7 @@ class testgrad_sources_inputs(unittest.TestCase):
gval
=
theano
.
tensor
.
matrix
()
gval
=
theano
.
tensor
.
matrix
()
class
O
(
gof
.
op
.
Op
):
class
O
(
gof
.
op
.
Op
):
__props__
=
()
def
make_node
(
self
):
def
make_node
(
self
):
inputs
=
[
theano
.
tensor
.
matrix
()]
inputs
=
[
theano
.
tensor
.
matrix
()]
outputs
=
[
theano
.
tensor
.
matrix
()]
outputs
=
[
theano
.
tensor
.
matrix
()]
...
@@ -88,6 +91,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -88,6 +91,7 @@ class testgrad_sources_inputs(unittest.TestCase):
gval
=
theano
.
tensor
.
matrix
()
gval
=
theano
.
tensor
.
matrix
()
class
O
(
gof
.
op
.
Op
):
class
O
(
gof
.
op
.
Op
):
__props__
=
()
def
make_node
(
self
):
def
make_node
(
self
):
inputs
=
[
theano
.
tensor
.
matrix
()]
inputs
=
[
theano
.
tensor
.
matrix
()]
outputs
=
[
theano
.
tensor
.
scalar
(),
theano
.
tensor
.
scalar
()]
outputs
=
[
theano
.
tensor
.
scalar
(),
theano
.
tensor
.
scalar
()]
...
@@ -107,6 +111,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -107,6 +111,7 @@ class testgrad_sources_inputs(unittest.TestCase):
gval1
=
theano
.
tensor
.
scalar
()
gval1
=
theano
.
tensor
.
scalar
()
class
O
(
gof
.
op
.
Op
):
class
O
(
gof
.
op
.
Op
):
__props__
=
()
def
make_node
(
self
):
def
make_node
(
self
):
inputs
=
[
theano
.
tensor
.
scalar
(),
theano
.
tensor
.
scalar
()]
inputs
=
[
theano
.
tensor
.
scalar
(),
theano
.
tensor
.
scalar
()]
outputs
=
[
theano
.
tensor
.
matrix
()]
outputs
=
[
theano
.
tensor
.
matrix
()]
...
@@ -127,6 +132,7 @@ class testgrad_sources_inputs(unittest.TestCase):
...
@@ -127,6 +132,7 @@ class testgrad_sources_inputs(unittest.TestCase):
gval1
=
theano
.
tensor
.
matrix
()
gval1
=
theano
.
tensor
.
matrix
()
class
O
(
gof
.
op
.
Op
):
class
O
(
gof
.
op
.
Op
):
__props__
=
()
def
make_node
(
self
):
def
make_node
(
self
):
inputs
=
[
theano
.
tensor
.
matrix
(),
theano
.
tensor
.
matrix
()]
inputs
=
[
theano
.
tensor
.
matrix
(),
theano
.
tensor
.
matrix
()]
outputs
=
[
theano
.
tensor
.
matrix
(),
theano
.
tensor
.
matrix
()]
outputs
=
[
theano
.
tensor
.
matrix
(),
theano
.
tensor
.
matrix
()]
...
@@ -161,6 +167,7 @@ class test_grad(unittest.TestCase):
...
@@ -161,6 +167,7 @@ class test_grad(unittest.TestCase):
# tests that unimplemented grads are caught in the grad method
# tests that unimplemented grads are caught in the grad method
class
DummyOp
(
gof
.
Op
):
class
DummyOp
(
gof
.
Op
):
__props__
=
()
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
return
gof
.
Apply
(
self
,
[
x
],
[
x
.
type
()])
return
gof
.
Apply
(
self
,
[
x
],
[
x
.
type
()])
...
@@ -350,6 +357,7 @@ class test_grad(unittest.TestCase):
...
@@ -350,6 +357,7 @@ class test_grad(unittest.TestCase):
# Op1 has two outputs, f and g
# Op1 has two outputs, f and g
# x is connected to f but not to g
# x is connected to f but not to g
class
Op1
(
theano
.
gof
.
Op
):
class
Op1
(
theano
.
gof
.
Op
):
__props__
=
()
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
return
theano
.
Apply
(
self
,
inputs
=
[
x
],
return
theano
.
Apply
(
self
,
inputs
=
[
x
],
outputs
=
[
x
.
type
(),
theano
.
tensor
.
scalar
()])
outputs
=
[
x
.
type
(),
theano
.
tensor
.
scalar
()])
...
@@ -363,6 +371,7 @@ class test_grad(unittest.TestCase):
...
@@ -363,6 +371,7 @@ class test_grad(unittest.TestCase):
# Op2 has two inputs, f and g
# Op2 has two inputs, f and g
# Its gradient with respect to g is not defined
# Its gradient with respect to g is not defined
class
Op2
(
theano
.
gof
.
Op
):
class
Op2
(
theano
.
gof
.
Op
):
__props__
=
()
def
make_node
(
self
,
f
,
g
):
def
make_node
(
self
,
f
,
g
):
return
theano
.
Apply
(
self
,
inputs
=
[
f
,
g
],
return
theano
.
Apply
(
self
,
inputs
=
[
f
,
g
],
outputs
=
[
theano
.
tensor
.
scalar
()])
outputs
=
[
theano
.
tensor
.
scalar
()])
...
...
theano/tests/test_rop.py
浏览文件 @
b8374e28
...
@@ -34,11 +34,7 @@ class BreakRop(Op):
...
@@ -34,11 +34,7 @@ class BreakRop(Op):
"""
"""
@note: Non-differentiable.
@note: Non-differentiable.
"""
"""
def
__hash__
(
self
):
__props__
=
()
return
hash
(
type
(
self
))
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
return
Apply
(
self
,
[
x
],
[
x
.
type
()])
return
Apply
(
self
,
[
x
],
[
x
.
type
()])
...
...
theano/tests/test_tutorial.py
浏览文件 @
b8374e28
...
@@ -139,16 +139,13 @@ class T_extending(unittest.TestCase):
...
@@ -139,16 +139,13 @@ class T_extending(unittest.TestCase):
from
theano
import
gof
from
theano
import
gof
class
BinaryDoubleOp
(
gof
.
Op
):
class
BinaryDoubleOp
(
gof
.
Op
):
__props__
=
(
"name"
,
"fn"
)
def
__init__
(
self
,
name
,
fn
):
def
__init__
(
self
,
name
,
fn
):
self
.
name
=
name
self
.
name
=
name
self
.
fn
=
fn
self
.
fn
=
fn
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
and
(
self
.
name
==
other
.
name
)
and
(
self
.
fn
==
other
.
fn
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
^
hash
(
self
.
name
)
^
hash
(
self
.
fn
)
def
make_node
(
self
,
x
,
y
):
def
make_node
(
self
,
x
,
y
):
if
isinstance
(
x
,
(
int
,
float
)):
if
isinstance
(
x
,
(
int
,
float
)):
x
=
gof
.
Constant
(
double
,
x
)
x
=
gof
.
Constant
(
double
,
x
)
...
@@ -207,16 +204,13 @@ class T_extending(unittest.TestCase):
...
@@ -207,16 +204,13 @@ class T_extending(unittest.TestCase):
double
=
Double
()
double
=
Double
()
class
BinaryDoubleOp
(
gof
.
Op
):
class
BinaryDoubleOp
(
gof
.
Op
):
__props__
=
(
"name"
,
"fn"
)
def
__init__
(
self
,
name
,
fn
):
def
__init__
(
self
,
name
,
fn
):
self
.
name
=
name
self
.
name
=
name
self
.
fn
=
fn
self
.
fn
=
fn
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
and
(
self
.
name
==
other
.
name
)
and
(
self
.
fn
==
other
.
fn
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
^
hash
(
self
.
name
)
^
hash
(
self
.
fn
)
def
make_node
(
self
,
x
,
y
):
def
make_node
(
self
,
x
,
y
):
if
isinstance
(
x
,
(
int
,
float
)):
if
isinstance
(
x
,
(
int
,
float
)):
x
=
gof
.
Constant
(
double
,
x
)
x
=
gof
.
Constant
(
double
,
x
)
...
@@ -366,6 +360,8 @@ class T_extending(unittest.TestCase):
...
@@ -366,6 +360,8 @@ class T_extending(unittest.TestCase):
from
theano
import
gof
from
theano
import
gof
class
BinaryDoubleOp
(
gof
.
Op
):
class
BinaryDoubleOp
(
gof
.
Op
):
__props__
=
(
"name"
,
"fn"
,
"ccode"
)
def
__init__
(
self
,
name
,
fn
,
ccode
):
def
__init__
(
self
,
name
,
fn
,
ccode
):
self
.
name
=
name
self
.
name
=
name
self
.
fn
=
fn
self
.
fn
=
fn
...
@@ -1012,14 +1008,8 @@ class T_using_gpu(unittest.TestCase):
...
@@ -1012,14 +1008,8 @@ class T_using_gpu(unittest.TestCase):
raise
SkipTest
(
'Optional package cuda disabled'
)
raise
SkipTest
(
'Optional package cuda disabled'
)
class
PyCUDADoubleOp
(
theano
.
Op
):
class
PyCUDADoubleOp
(
theano
.
Op
):
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
__props__
=
()
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
inp
):
def
make_node
(
self
,
inp
):
inp
=
cuda
.
basic_ops
.
gpu_contiguous
(
inp
=
cuda
.
basic_ops
.
gpu_contiguous
(
...
@@ -1061,12 +1051,7 @@ class Fibby(theano.Op):
...
@@ -1061,12 +1051,7 @@ class Fibby(theano.Op):
"""
"""
An arbitrarily generalized Fibbonacci sequence
An arbitrarily generalized Fibbonacci sequence
"""
"""
__props__
=
()
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
x_
=
theano
.
tensor
.
as_tensor_variable
(
x
)
x_
=
theano
.
tensor
.
as_tensor_variable
(
x
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论