Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
tensorflow
提交
bcdc5c3a
T
tensorflow
项目概览
xxadev
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
1
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,发现更多精彩内容 >>
提交
bcdc5c3a
编写于
3月 15, 2017
作者:
J
Jianwei Xie
提交者:
TensorFlower Gardener
3月 15, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove the default value of `shuffle` for input fns.
Change: 150192601
上级
3c5de853
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
71 addition
and
9 deletion
+71
-9
tensorflow/contrib/learn/python/learn/learn_io/numpy_io.py
tensorflow/contrib/learn/python/learn/learn_io/numpy_io.py
+18
-3
tensorflow/contrib/learn/python/learn/learn_io/pandas_io.py
tensorflow/contrib/learn/python/learn/learn_io/pandas_io.py
+20
-1
tensorflow/python/estimator/inputs/numpy_io.py
tensorflow/python/estimator/inputs/numpy_io.py
+7
-3
tensorflow/python/estimator/inputs/numpy_io_test.py
tensorflow/python/estimator/inputs/numpy_io_test.py
+9
-0
tensorflow/python/estimator/inputs/pandas_io.py
tensorflow/python/estimator/inputs/pandas_io.py
+7
-2
tensorflow/python/estimator/inputs/pandas_io_test.py
tensorflow/python/estimator/inputs/pandas_io_test.py
+10
-0
未找到文件。
tensorflow/contrib/learn/python/learn/learn_io/numpy_io.py
浏览文件 @
bcdc5c3a
...
...
@@ -18,6 +18,21 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
# pylint: disable=unused-import
from
tensorflow.python.estimator.inputs.numpy_io
import
numpy_input_fn
# pylint: enable=unused-import
from
tensorflow.python.estimator.inputs.numpy_io
import
numpy_input_fn
as
core_numpy_input_fn
def
numpy_input_fn
(
x
,
y
=
None
,
batch_size
=
128
,
num_epochs
=
1
,
shuffle
=
True
,
queue_capacity
=
1000
,
num_threads
=
1
):
"""This input_fn diffs from the core version with default `shuffle`."""
return
core_numpy_input_fn
(
x
=
x
,
y
=
y
,
batch_size
=
batch_size
,
shuffle
=
shuffle
,
num_epochs
=
num_epochs
,
queue_capacity
=
queue_capacity
,
num_threads
=
num_threads
)
tensorflow/contrib/learn/python/learn/learn_io/pandas_io.py
浏览文件 @
bcdc5c3a
...
...
@@ -19,7 +19,7 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
tensorflow.python.estimator.inputs.pandas_io
import
pandas_input_fn
# pylint: disable=unused-import
from
tensorflow.python.estimator.inputs.pandas_io
import
pandas_input_fn
as
core_pandas_input_fn
try
:
# pylint: disable=g-import-not-at-top
...
...
@@ -47,6 +47,25 @@ PANDAS_DTYPES = {
}
def
pandas_input_fn
(
x
,
y
=
None
,
batch_size
=
128
,
num_epochs
=
1
,
shuffle
=
True
,
queue_capacity
=
1000
,
num_threads
=
1
,
target_column
=
'target'
):
"""This input_fn diffs from the core version with default `shuffle`."""
return
core_pandas_input_fn
(
x
=
x
,
y
=
y
,
batch_size
=
batch_size
,
shuffle
=
shuffle
,
num_epochs
=
num_epochs
,
queue_capacity
=
queue_capacity
,
num_threads
=
num_threads
,
target_column
=
target_column
)
def
extract_pandas_data
(
data
):
"""Extract data from pandas.DataFrame for predictors.
...
...
tensorflow/python/estimator/inputs/numpy_io.py
浏览文件 @
bcdc5c3a
...
...
@@ -46,7 +46,7 @@ def numpy_input_fn(x,
y
=
None
,
batch_size
=
128
,
num_epochs
=
1
,
shuffle
=
Tru
e
,
shuffle
=
Non
e
,
queue_capacity
=
1000
,
num_threads
=
1
):
"""Returns input function that would feed dict of numpy arrays into the model.
...
...
@@ -68,7 +68,7 @@ def numpy_input_fn(x,
Args:
x: dict of numpy array object.
y: numpy array object.
y: numpy array object.
`None` if absent.
batch_size: Integer, size of batches to return.
num_epochs: Integer, number of epochs to iterate over data. If `None` will
run forever.
...
...
@@ -83,9 +83,13 @@ def numpy_input_fn(x,
Raises:
ValueError: if the shape of `y` mismatches the shape of values in `x` (i.e.,
values in `x` have same shape).
TypeError: `x` is not a dict.
TypeError: `x` is not a dict
or `shuffle` is not bool
.
"""
if
not
isinstance
(
shuffle
,
bool
):
raise
TypeError
(
'shuffle must be explicitly set as boolean; '
'got {}'
.
format
(
shuffle
))
def
input_fn
():
"""Numpy input function."""
if
not
isinstance
(
x
,
dict
):
...
...
tensorflow/python/estimator/inputs/numpy_io_test.py
浏览文件 @
bcdc5c3a
...
...
@@ -239,6 +239,15 @@ class NumpyIoTest(test.TestCase):
x
,
y
,
batch_size
=
2
,
shuffle
=
False
,
num_epochs
=
1
)
failing_input_fn
()
def
testNumpyInputFnWithNonBoolShuffle
(
self
):
x
=
np
.
arange
(
32
,
36
)
y
=
np
.
arange
(
4
)
with
self
.
test_session
():
with
self
.
assertRaisesRegexp
(
TypeError
,
'shuffle must be explicitly set as boolean'
):
# Default shuffle is None.
numpy_io
.
numpy_input_fn
(
x
,
y
)
def
testNumpyInputFnWithTargetKeyAlreadyInX
(
self
):
array
=
np
.
arange
(
32
,
36
)
x
=
{
'__target_key__'
:
array
}
...
...
tensorflow/python/estimator/inputs/pandas_io.py
浏览文件 @
bcdc5c3a
...
...
@@ -38,7 +38,7 @@ def pandas_input_fn(x,
y
=
None
,
batch_size
=
128
,
num_epochs
=
1
,
shuffle
=
Tru
e
,
shuffle
=
Non
e
,
queue_capacity
=
1000
,
num_threads
=
1
,
target_column
=
'target'
):
...
...
@@ -48,7 +48,7 @@ def pandas_input_fn(x,
Args:
x: pandas `DataFrame` object.
y: pandas `Series` object.
y: pandas `Series` object.
`None` if absent.
batch_size: int, size of batches to return.
num_epochs: int, number of epochs to iterate over data. If not `None`,
read attempts that would exceed this value will raise `OutOfRangeError`.
...
...
@@ -64,11 +64,16 @@ def pandas_input_fn(x,
Raises:
ValueError: if `x` already contains a column with the same name as `y`, or
if the indexes of `x` and `y` don't match.
TypeError: `shuffle` is not bool.
"""
if
not
HAS_PANDAS
:
raise
TypeError
(
'pandas_input_fn should not be called without pandas installed'
)
if
not
isinstance
(
shuffle
,
bool
):
raise
TypeError
(
'shuffle must be explicitly set as boolean; '
'got {}'
.
format
(
shuffle
))
x
=
x
.
copy
()
if
y
is
not
None
:
if
target_column
in
x
:
...
...
tensorflow/python/estimator/inputs/pandas_io_test.py
浏览文件 @
bcdc5c3a
...
...
@@ -65,6 +65,16 @@ class PandasIoTest(test.TestCase):
pandas_io
.
pandas_input_fn
(
x
,
y_noindex
,
batch_size
=
2
,
shuffle
=
False
,
num_epochs
=
1
)
def
testPandasInputFn_NonBoolShuffle
(
self
):
if
not
HAS_PANDAS
:
return
x
,
_
=
self
.
makeTestDataFrame
()
y_noindex
=
pd
.
Series
(
np
.
arange
(
-
32
,
-
28
))
with
self
.
assertRaisesRegexp
(
TypeError
,
'shuffle must be explicitly set as boolean'
):
# Default shuffle is None
pandas_io
.
pandas_input_fn
(
x
,
y_noindex
)
def
testPandasInputFn_ProducesExpectedOutputs
(
self
):
if
not
HAS_PANDAS
:
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录