Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fef231b0
提交
fef231b0
authored
5月 30, 2012
作者:
Matthew Rocklin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
path is now treated as a theano variable
上级
211bc60d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
13 行删除
+18
-13
basic.py
theano/tensor/basic.py
+14
-10
test_basic.py
theano/tensor/tests/test_basic.py
+4
-3
没有找到文件。
theano/tensor/basic.py
浏览文件 @
fef231b0
...
...
@@ -2029,30 +2029,34 @@ class LoadFromDisk(Op):
"""
@note: Non-differentiable.
"""
def
__init__
(
self
,
path
,
dtype
):
self
.
path
=
path
def
__init__
(
self
,
dtype
,
broadcastable
):
self
.
dtype
=
dtype
self
.
broadcastable
=
broadcastable
def
__eq__
(
self
,
other
):
return
(
type
(
self
)
==
type
(
other
)
and
self
.
path
==
other
.
path
and
self
.
broadcastable
==
other
.
broadcastable
and
self
.
dtype
==
other
.
dtype
)
def
__hash__
(
self
):
return
hash
((
type
(
self
),
self
.
path
,
self
.
dtyp
e
))
return
hash
((
type
(
self
),
self
.
dtype
,
self
.
broadcastabl
e
))
def
make_node
(
self
):
return
gof
.
Apply
(
self
,
[],
[
tensor
(
self
.
dtype
,
broadcastable
=
(
False
,))])
def
make_node
(
self
,
path
):
if
isinstance
(
path
,
str
):
path
=
Constant
(
Generic
(),
path
)
return
gof
.
Apply
(
self
,
[
path
],
[
tensor
(
self
.
dtype
,
broadcastable
=
self
.
broadcastable
)])
def
perform
(
self
,
node
,
inp
,
out
):
d
=
numpy
.
load
(
self
.
path
)
path
=
inp
[
0
]
d
=
numpy
.
load
(
path
)
out
[
0
][
0
]
=
d
[
d
.
keys
()[
0
]]
.
astype
(
self
.
dtype
)
def
__str__
(
self
):
return
"Load:
%
s
"
%
self
.
path
return
"Load:
%
s
,
%
s"
%
(
self
.
dtype
,
self
.
broadcastable
)
def
load
(
path
,
dtype
=
'float64'
):
return
LoadFromDisk
(
path
,
dtype
)(
)
def
load
(
path
,
dtype
,
broadcastable
):
return
LoadFromDisk
(
dtype
,
broadcastable
)(
path
)
##########################
# Unary Operations
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
fef231b0
...
...
@@ -3969,10 +3969,11 @@ class T_load_tensor(unittest.TestCase):
data
=
numpy
.
arange
(
5
)
filename
=
"_load_tensor_test_1.npz"
numpy
.
savez
(
filename
,
data
)
x
=
tensor
.
load
(
filename
,
'int64'
)
path
=
Variable
(
Generic
())
x
=
tensor
.
load
(
path
,
'int64'
,
(
False
,))
y
=
x
*
2
fn
=
function
([],
[
y
])
assert
(
fn
()
==
data
*
2
)
.
all
()
fn
=
function
([
path
],
[
y
])
assert
(
fn
(
filename
)
==
data
*
2
)
.
all
()
class
test_grad
(
unittest
.
TestCase
):
class
O
(
gof
.
op
.
Op
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论