Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
slsbkm
tensorflow
提交
423c1eea
T
tensorflow
项目概览
slsbkm
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
423c1eea
编写于
7月 26, 2017
作者:
A
A. Unique TensorFlower
提交者:
TensorFlower Gardener
7月 26, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BREAKING CHANGE: Fix semantic error in how maybe_batch* handles sparse tensors.
PiperOrigin-RevId: 163276613
上级
6028c071
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
1 deletion
+54
-1
tensorflow/python/training/input.py
tensorflow/python/training/input.py
+8
-1
tensorflow/python/training/input_test.py
tensorflow/python/training/input_test.py
+46
-0
未找到文件。
tensorflow/python/training/input.py
浏览文件 @
423c1eea
...
...
@@ -492,8 +492,15 @@ def _store_sparse_tensors(tensor_list, enqueue_many, keep_input,
lambda
:
-
1
*
array_ops
.
ones
(
array_ops
.
shape
(
t
)[
0
:
1
],
dtypes
.
int64
))
out_tensor
.
set_shape
([
None
])
# necessary when t.ndims is unknown
return
out_tensor
def
_sparse_values_to_keep
(
t
,
keep_input
):
"""Convert a per-row `keep_input` vector to a per-value one."""
# Get the rows of every value in the sparse Tensor.
row_values
=
array_ops
.
reshape
(
t
.
indices
,
[
array_ops
.
shape
(
t
.
indices
)[
0
],
-
1
])[:,
0
]
# The value should be kept iff the row should be kept.
return
array_ops
.
gather
(
keep_input
,
row_values
)
if
keep_input
.
shape
.
ndims
==
1
:
t
=
sparse_ops
.
sparse_retain
(
t
,
keep_input
)
t
=
sparse_ops
.
sparse_retain
(
t
,
_sparse_values_to_keep
(
t
,
keep_input
)
)
store_f
=
lambda
t
,
name
,
_
:
_store_many_sparse
(
t
,
shared_name
=
name
)
elif
enqueue_many
:
store_f
=
_maybe_store_many_sparse
...
...
tensorflow/python/training/input_test.py
浏览文件 @
423c1eea
...
...
@@ -903,6 +903,29 @@ class BatchTest(test_lib.TestCase):
[
sparse
],
keep_input
=
[
True
,
False
],
batch_size
=
2
,
enqueue_many
=
True
)
self
.
assertIs
(
None
,
batched
.
dense_shape
.
get_shape
().
num_elements
())
def
testMaybeBatchCorrectValues
(
self
):
sparse_t
=
sparse_tensor
.
SparseTensor
(
indices
=
[[
0
,
1
],
[
0
,
2
],
[
1
,
0
],
[
1
,
3
]],
dense_shape
=
[
2
,
4
],
values
=
[
5
,
4
,
7
,
2
])
keep
=
constant_op
.
constant
([
True
,
False
])
batched
=
inp
.
maybe_batch
(
[
sparse_t
],
keep_input
=
keep
,
batch_size
=
1
,
enqueue_many
=
True
)
with
self
.
test_session
():
coord
=
coordinator
.
Coordinator
()
threads
=
queue_runner_impl
.
start_queue_runners
(
coord
=
coord
)
batched_np
=
batched
.
eval
()
coord
.
request_stop
()
for
thread
in
threads
:
thread
.
join
()
self
.
assertAllEqual
([[
0
,
1
],
[
0
,
2
]],
batched_np
.
indices
)
self
.
assertAllEqual
([
5
,
4
],
batched_np
.
values
)
self
.
assertAllEqual
([
1
,
4
],
batched_np
.
dense_shape
)
class
BatchJoinTest
(
test_lib
.
TestCase
):
...
...
@@ -1457,6 +1480,29 @@ class BatchJoinTest(test_lib.TestCase):
[[
sparse
]],
keep_input
=
[
True
,
False
],
batch_size
=
2
,
enqueue_many
=
True
)
self
.
assertIs
(
None
,
batched
.
dense_shape
.
get_shape
().
num_elements
())
def
testMaybeBatchCorrectValues
(
self
):
sparse
=
sparse_tensor
.
SparseTensor
(
indices
=
[[
0
,
1
],
[
0
,
2
],
[
1
,
0
],
[
1
,
3
]],
dense_shape
=
[
2
,
4
],
values
=
[
5
,
4
,
7
,
2
])
keep
=
constant_op
.
constant
([
True
,
False
])
batched
=
inp
.
maybe_batch_join
(
[[
sparse
]],
keep_input
=
keep
,
batch_size
=
1
,
enqueue_many
=
True
)
with
self
.
test_session
():
coord
=
coordinator
.
Coordinator
()
threads
=
queue_runner_impl
.
start_queue_runners
(
coord
=
coord
)
batched_np
=
batched
.
eval
()
coord
.
request_stop
()
for
thread
in
threads
:
thread
.
join
()
self
.
assertAllEqual
([[
0
,
1
],
[
0
,
2
]],
batched_np
.
indices
)
self
.
assertAllEqual
([
5
,
4
],
batched_np
.
values
)
self
.
assertAllEqual
([
1
,
4
],
batched_np
.
dense_shape
)
class
ShuffleBatchTest
(
test_lib
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录