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
c3fa06d7
Commit
c3fa06d7
authored
7 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Add keyword argument to flag the shuffling mechanism
parent
171ede05
No related branches found
No related tags found
1 merge request
!17
Updates
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/datashuffler/TFRecord.py
+16
-4
16 additions, 4 deletions
bob/learn/tensorflow/datashuffler/TFRecord.py
with
16 additions
and
4 deletions
bob/learn/tensorflow/datashuffler/TFRecord.py
+
16
−
4
View file @
c3fa06d7
...
...
@@ -12,13 +12,19 @@ from bob.learn.tensorflow.datashuffler.Normalizer import Linear
class
TFRecord
(
object
):
"""
Datashuffler that wraps tfrecords
"""
def
__init__
(
self
,
filename_queue
,
input_shape
=
[
None
,
28
,
28
,
1
],
input_dtype
=
"
float32
"
,
batch_size
=
32
,
seed
=
10
,
prefetch_capacity
=
50
,
prefetch_threads
=
5
):
prefetch_threads
=
5
,
shuffle
=
True
):
# Setting the seed for the pseudo random number generator
self
.
seed
=
seed
...
...
@@ -40,6 +46,8 @@ class TFRecord(object):
self
.
data_ph
=
None
self
.
label_ph
=
None
self
.
shuffle
=
shuffle
def
__call__
(
self
,
element
,
from_queue
=
False
):
"""
...
...
@@ -83,10 +91,14 @@ class TFRecord(object):
# Reshape image data into the original shape
image
=
tf
.
reshape
(
image
,
self
.
input_shape
[
1
:])
if
self
.
shuffle
:
data_ph
,
label_ph
=
tf
.
train
.
shuffle_batch
([
image
,
label
],
batch_size
=
self
.
batch_size
,
capacity
=
self
.
prefetch_capacity
,
num_threads
=
self
.
prefetch_threads
,
min_after_dequeue
=
1
,
name
=
"
shuffle_batch
"
)
else
:
data_ph
,
label_ph
=
tf
.
train
.
batch
([
image
,
label
],
batch_size
=
self
.
batch_size
,
capacity
=
self
.
prefetch_capacity
,
num_threads
=
self
.
prefetch_threads
,
name
=
"
batch
"
)
data_ph
,
label_ph
=
tf
.
train
.
shuffle_batch
([
image
,
label
],
batch_size
=
self
.
batch_size
,
capacity
=
self
.
prefetch_capacity
,
num_threads
=
self
.
prefetch_threads
,
min_after_dequeue
=
1
,
name
=
"
shuffle_batch
"
)
self
.
data_ph
=
data_ph
...
...
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