Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d5ae91e1
提交
d5ae91e1
authored
10月 21, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
included module in theano.compile
上级
664e4261
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
42 行增加
和
42 行删除
+42
-42
logistic_regression.py
examples/logistic_regression.py
+1
-1
__init__.py
theano/compile/__init__.py
+3
-0
module.py
theano/compile/module.py
+13
-40
__init__.py
theano/tensor/__init__.py
+1
-1
raw_random.py
theano/tensor/raw_random.py
+24
-0
没有找到文件。
examples/logistic_regression.py
浏览文件 @
d5ae91e1
...
@@ -3,7 +3,7 @@ sys.path.insert(0, '..')
...
@@ -3,7 +3,7 @@ sys.path.insert(0, '..')
import
theano
import
theano
from
theano
import
tensor
as
T
from
theano
import
tensor
as
T
from
theano.tensor
import
nnet_ops
from
theano.tensor
import
nnet_ops
from
theano.
sandbox
import
module
from
theano.
compile
import
module
from
theano.sandbox
import
pprint
from
theano.sandbox
import
pprint
import
numpy
as
N
import
numpy
as
N
...
...
theano/compile/__init__.py
浏览文件 @
d5ae91e1
...
@@ -11,3 +11,6 @@ from io import *
...
@@ -11,3 +11,6 @@ from io import *
import
builders
import
builders
from
builders
import
*
from
builders
import
*
import
module
from
module
import
*
theano/
sandbox
/module.py
→
theano/
compile
/module.py
浏览文件 @
d5ae91e1
import
theano
from
..
import
gof
from
theano
import
gof
,
compile
from
collections
import
defaultdict
from
collections
import
defaultdict
from
itertools
import
chain
from
itertools
import
chain
from
functools
import
partial
from
functools
import
partial
from
theano.gof.utils
import
scratchpad
from
copy
import
copy
from
copy
import
copy
import
mode
import
function_module
as
F
#from ..sandbox import pprint
def
join
(
*
args
):
def
join
(
*
args
):
...
@@ -137,7 +137,6 @@ class Member(_RComponent):
...
@@ -137,7 +137,6 @@ class Member(_RComponent):
from
theano.sandbox
import
pprint
class
Method
(
Component
):
class
Method
(
Component
):
def
__init__
(
self
,
inputs
,
outputs
,
updates
=
{},
kits
=
[],
**
kwupdates
):
def
__init__
(
self
,
inputs
,
outputs
,
updates
=
{},
kits
=
[],
**
kwupdates
):
...
@@ -197,13 +196,13 @@ class Method(Component):
...
@@ -197,13 +196,13 @@ class Method(Component):
else
:
else
:
return
gof
.
Container
(
r
,
storage
=
[
None
])
return
gof
.
Container
(
r
,
storage
=
[
None
])
inputs
=
self
.
inputs
inputs
=
self
.
inputs
inputs
=
[
compil
e
.
In
(
result
=
input
,
inputs
=
[
mod
e
.
In
(
result
=
input
,
value
=
get_storage
(
input
))
value
=
get_storage
(
input
))
for
input
in
inputs
]
for
input
in
inputs
]
inputs
+=
[
compil
e
.
In
(
result
=
k
,
inputs
+=
[
mod
e
.
In
(
result
=
k
,
update
=
v
,
update
=
v
,
value
=
get_storage
(
k
,
True
),
value
=
get_storage
(
k
,
True
),
strict
=
True
)
strict
=
True
)
for
k
,
v
in
self
.
updates
.
iteritems
()]
for
k
,
v
in
self
.
updates
.
iteritems
()]
outputs
=
self
.
outputs
outputs
=
self
.
outputs
_inputs
=
[
x
.
result
for
x
in
inputs
]
_inputs
=
[
x
.
result
for
x
in
inputs
]
...
@@ -211,10 +210,10 @@ class Method(Component):
...
@@ -211,10 +210,10 @@ class Method(Component):
+
[
x
.
update
for
x
in
inputs
if
getattr
(
x
,
'update'
,
False
)],
+
[
x
.
update
for
x
in
inputs
if
getattr
(
x
,
'update'
,
False
)],
blockers
=
_inputs
):
blockers
=
_inputs
):
if
input
not
in
_inputs
and
not
isinstance
(
input
,
gof
.
Value
):
if
input
not
in
_inputs
and
not
isinstance
(
input
,
gof
.
Value
):
inputs
+=
[
compil
e
.
In
(
result
=
input
,
inputs
+=
[
mod
e
.
In
(
result
=
input
,
value
=
get_storage
(
input
,
True
))]
value
=
get_storage
(
input
,
True
))]
inputs
+=
[(
kit
,
get_storage
(
kit
,
True
))
for
kit
in
self
.
kits
]
inputs
+=
[(
kit
,
get_storage
(
kit
,
True
))
for
kit
in
self
.
kits
]
return
compile
.
function
(
inputs
,
outputs
,
mode
)
return
F
.
function
(
inputs
,
outputs
,
mode
)
def
pretty
(
self
,
**
kwargs
):
def
pretty
(
self
,
**
kwargs
):
self
.
resolve_all
()
self
.
resolve_all
()
...
@@ -627,32 +626,6 @@ class KitComponent(Component):
...
@@ -627,32 +626,6 @@ class KitComponent(Component):
return
memo
[
self
.
kit
]
return
memo
[
self
.
kit
]
from
..
import
tensor
as
T
class
RModule
(
FancyModule
):
def
__init__
(
self
,
components
=
{},
**
kwcomponents
):
super
(
RModule
,
self
)
.
__init__
(
components
,
**
kwcomponents
)
self
.
random
=
T
.
RandomKit
(
'rkit'
)
self
.
_components
[
'_rkit'
]
=
KitComponent
(
self
.
random
)
def
__wrapper__
(
self
,
x
):
x
=
wrap
(
x
)
if
isinstance
(
x
,
Method
):
x
.
kits
+=
[
self
.
random
]
return
x
def
_instance_seed
(
self
,
inst
,
seed
,
recursive
=
True
):
if
recursive
:
for
path
,
c
in
self
.
flat_components_map
(
True
):
if
isinstance
(
c
,
RModule
):
inst2
=
inst
for
name
in
path
:
inst2
=
inst2
[
name
]
c
.
_rkit
.
kit
.
distribute
(
seed
,
xrange
(
len
(
inst
.
_rkit
)),
inst2
.
_rkit
)
else
:
self
.
_rkit
.
kit
.
distribute
(
seed
,
xrange
(
len
(
inst
.
_rkit
)),
inst
.
_rkit
)
...
...
theano/tensor/__init__.py
浏览文件 @
d5ae91e1
...
@@ -5,7 +5,7 @@ import opt
...
@@ -5,7 +5,7 @@ import opt
import
raw_random
import
raw_random
from
raw_random
import
\
from
raw_random
import
\
RandomKit
RandomKit
,
RModule
random
=
RandomKit
(
'random'
)
random
=
RandomKit
(
'random'
)
...
...
theano/tensor/raw_random.py
浏览文件 @
d5ae91e1
...
@@ -4,6 +4,7 @@ import basic as tensor
...
@@ -4,6 +4,7 @@ import basic as tensor
import
numpy
import
numpy
import
functools
import
functools
from
..
import
compile
from
..compile
import
SymbolicInputKit
,
SymbolicInput
from
..compile
import
SymbolicInputKit
,
SymbolicInput
from
copy
import
copy
from
copy
import
copy
...
@@ -231,3 +232,26 @@ class RandomKit(SymbolicInputKit):
...
@@ -231,3 +232,26 @@ class RandomKit(SymbolicInputKit):
rk
=
RandomKit
(
'rk'
,
0xBAD5EED
)
rk
=
RandomKit
(
'rk'
,
0xBAD5EED
)
class
RModule
(
compile
.
FancyModule
):
def
__init__
(
self
,
components
=
{},
**
kwcomponents
):
super
(
RModule
,
self
)
.
__init__
(
components
,
**
kwcomponents
)
self
.
random
=
T
.
RandomKit
(
'rkit'
)
self
.
_components
[
'_rkit'
]
=
KitComponent
(
self
.
random
)
def
__wrapper__
(
self
,
x
):
x
=
wrap
(
x
)
if
isinstance
(
x
,
compile
.
Method
):
x
.
kits
+=
[
self
.
random
]
return
x
def
_instance_seed
(
self
,
inst
,
seed
,
recursive
=
True
):
if
recursive
:
for
path
,
c
in
self
.
flat_components_map
(
True
):
if
isinstance
(
c
,
RModule
):
inst2
=
inst
for
name
in
path
:
inst2
=
inst2
[
name
]
c
.
_rkit
.
kit
.
distribute
(
seed
,
xrange
(
len
(
inst
.
_rkit
)),
inst2
.
_rkit
)
else
:
self
.
_rkit
.
kit
.
distribute
(
seed
,
xrange
(
len
(
inst
.
_rkit
)),
inst
.
_rkit
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论