Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
205a9ff4
Commit
205a9ff4
authored
Dec 14, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add datafromiterable
parent
6afeb544
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
tensorpack/dataflow/raw.py
tensorpack/dataflow/raw.py
+20
-2
No files found.
tensorpack/dataflow/raw.py
View file @
205a9ff4
...
...
@@ -10,7 +10,7 @@ from six.moves import range
from
.base
import
DataFlow
,
RNGDataFlow
from
..utils.develop
import
log_deprecated
__all__
=
[
'FakeData'
,
'DataFromQueue'
,
'DataFromList'
,
'DataFromGenerator'
]
__all__
=
[
'FakeData'
,
'DataFromQueue'
,
'DataFromList'
,
'DataFromGenerator'
,
'DataFromIterable'
]
class
FakeData
(
RNGDataFlow
):
...
...
@@ -70,7 +70,7 @@ class DataFromQueue(DataFlow):
class
DataFromList
(
RNGDataFlow
):
"""
Produce data from a list
"""
"""
Wrap a list of datapoitns to a DataFlow
"""
def
__init__
(
self
,
lst
,
shuffle
=
True
):
"""
...
...
@@ -116,3 +116,21 @@ class DataFromGenerator(DataFlow):
# yield from
for
dp
in
self
.
_gen
():
yield
dp
class
DataFromIterable
(
DataFlow
):
""" Wrap an iterable of datapoitns to a DataFlow"""
def
__init__
(
self
,
iterable
):
"""
Args:
iterable: an iterable object with length
"""
self
.
_itr
=
self
.
iterable
self
.
_len
=
len
(
iterable
)
def
size
(
self
):
return
self
.
_len
def
get_data
(
self
):
for
dp
in
self
.
_itr
:
yield
dp
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment