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
caac0743
"git@gitlab.idiap.ch:software/gridtk.git" did not exist on "1cc03e38d8df204748b46b857556196a8207704f"
Commit
caac0743
authored
6 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Added tests for the Generator dataset
parent
01ac7f66
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!75
A lot of new features
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/learn/tensorflow/dataset/generator.py
+2
-1
2 additions, 1 deletion
bob/learn/tensorflow/dataset/generator.py
bob/learn/tensorflow/test/test_dataset.py
+26
-0
26 additions, 0 deletions
bob/learn/tensorflow/test/test_dataset.py
with
28 additions
and
1 deletion
bob/learn/tensorflow/dataset/generator.py
+
2
−
1
View file @
caac0743
...
...
@@ -29,7 +29,7 @@ class Generator:
"""
def
__init__
(
self
,
samples
,
reader
,
multiple_samples
=
False
,
**
kwargs
):
super
(
Generator
,
self
).
__init__
(
**
kwargs
)
super
().
__init__
(
**
kwargs
)
self
.
reader
=
reader
self
.
samples
=
list
(
samples
)
self
.
multiple_samples
=
multiple_samples
...
...
@@ -43,6 +43,7 @@ class Generator:
except
TypeError
:
# if the data is a generator
dlk
=
six
.
next
(
dlk
)
# Creating a "fake" dataset just to get the types and shapes
dataset
=
tf
.
data
.
Dataset
.
from_tensors
(
dlk
)
self
.
_output_types
=
dataset
.
output_types
self
.
_output_shapes
=
dataset
.
output_shapes
...
...
This diff is collapsed.
Click to expand it.
bob/learn/tensorflow/test/test_dataset.py
+
26
−
0
View file @
caac0743
...
...
@@ -3,9 +3,11 @@
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
import
pkg_resources
import
numpy
import
tensorflow
as
tf
from
bob.learn.tensorflow.dataset.siamese_image
import
shuffle_data_and_labels_image_augmentation
as
siamese_batch
from
bob.learn.tensorflow.dataset.triplet_image
import
shuffle_data_and_labels_image_augmentation
as
triplet_batch
from
bob.learn.tensorflow.dataset.generator
import
dataset_using_generator
data_shape
=
(
250
,
250
,
3
)
output_shape
=
(
50
,
50
)
...
...
@@ -76,3 +78,27 @@ def test_triplet_dataset():
assert
d
[
'
anchor
'
].
shape
==
(
2
,
50
,
50
,
3
)
assert
d
[
'
positive
'
].
shape
==
(
2
,
50
,
50
,
3
)
assert
d
[
'
negative
'
].
shape
==
(
2
,
50
,
50
,
3
)
def
test_dataset_using_generator
():
def
reader
(
f
):
key
=
0
label
=
0
yield
{
'
data
'
:
f
,
'
key
'
:
key
},
label
shape
=
(
2
,
2
,
1
)
samples
=
[
numpy
.
ones
(
shape
,
dtype
=
"
float32
"
)
*
i
for
i
in
range
(
10
)]
with
tf
.
Session
()
as
session
:
dataset
=
dataset_using_generator
(
samples
,
\
reader
,
\
multiple_samples
=
True
)
iterator
=
dataset
.
make_one_shot_iterator
().
get_next
()
while
True
:
try
:
sample
=
session
.
run
(
iterator
)
assert
sample
[
0
][
"
data
"
].
shape
==
shape
except
tf
.
errors
.
OutOfRangeError
:
break
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