Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.tensorflow
Commits
5328bd78
Commit
5328bd78
authored
6 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
Add a parallel read option to dataset_from_tfrecords
parent
857275d3
No related branches found
No related tags found
1 merge request
!79
Add keras-based models, add pixel-wise loss, other improvements
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/dataset/tfrecords.py
+7
-2
7 additions, 2 deletions
bob/learn/tensorflow/dataset/tfrecords.py
with
7 additions
and
2 deletions
bob/learn/tensorflow/dataset/tfrecords.py
+
7
−
2
View file @
5328bd78
...
@@ -87,7 +87,7 @@ def dataset_to_tfrecord(dataset, output):
...
@@ -87,7 +87,7 @@ def dataset_to_tfrecord(dataset, output):
return
writer
.
write
(
dataset
)
return
writer
.
write
(
dataset
)
def
dataset_from_tfrecord
(
tfrecord
):
def
dataset_from_tfrecord
(
tfrecord
,
num_parallel_reads
=
None
):
"""
Reads TFRecords and returns a dataset.
"""
Reads TFRecords and returns a dataset.
The TFRecord file must have been created using the :any:`dataset_to_tfrecord`
The TFRecord file must have been created using the :any:`dataset_to_tfrecord`
function.
function.
...
@@ -97,6 +97,9 @@ def dataset_from_tfrecord(tfrecord):
...
@@ -97,6 +97,9 @@ def dataset_from_tfrecord(tfrecord):
tfrecord : str or list
tfrecord : str or list
Path to the TFRecord file. Pass a list if you are sure several tfrecords need
Path to the TFRecord file. Pass a list if you are sure several tfrecords need
the same map function.
the same map function.
num_parallel_reads: (Optional.)
A `tf.int64` scalar representing the number of files to read in parallel.
Defaults to reading files sequentially.
Returns
Returns
-------
-------
...
@@ -111,7 +114,9 @@ def dataset_from_tfrecord(tfrecord):
...
@@ -111,7 +114,9 @@ def dataset_from_tfrecord(tfrecord):
tfrecord
=
[
tfrecord_name_and_json_name
(
path
)
for
path
in
tfrecord
]
tfrecord
=
[
tfrecord_name_and_json_name
(
path
)
for
path
in
tfrecord
]
json_output
=
tfrecord
[
0
][
1
]
json_output
=
tfrecord
[
0
][
1
]
tfrecord
=
[
path
[
0
]
for
path
in
tfrecord
]
tfrecord
=
[
path
[
0
]
for
path
in
tfrecord
]
raw_dataset
=
tf
.
data
.
TFRecordDataset
(
tfrecord
)
raw_dataset
=
tf
.
data
.
TFRecordDataset
(
tfrecord
,
num_parallel_reads
=
num_parallel_reads
)
with
open
(
json_output
)
as
f
:
with
open
(
json_output
)
as
f
:
meta
=
json
.
load
(
f
)
meta
=
json
.
load
(
f
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment