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
1f2735c1
There was a problem fetching the pipeline summary.
Commit
1f2735c1
authored
7 years ago
by
Guillaume HEUSCH
Browse files
Options
Downloads
Patches
Plain Diff
[datashuffler] added the doc in DrGanDisk
parent
319ef692
No related branches found
No related tags found
1 merge request
!8
Gan
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/datashuffler/DrGanDisk.py
+60
-8
60 additions, 8 deletions
bob/learn/tensorflow/datashuffler/DrGanDisk.py
with
60 additions
and
8 deletions
bob/learn/tensorflow/datashuffler/DrGanDisk.py
+
60
−
8
View file @
1f2735c1
...
...
@@ -25,9 +25,11 @@ class DrGanDisk(Base):
data:
Input data
labels:
List of list containing labels
(we consider several labels per example)
id_labels:
id labels of the retrieved faces.
pose_labels:
pose labels of the retrieved faces.
input_shape:
The shape of the inputs
...
...
@@ -110,6 +112,19 @@ class DrGanDisk(Base):
return
self
.
data_placeholder
,
self
.
id_label_placeholder
,
self
.
pose_label_placeholder
def
load_from_file
(
self
,
file_name
):
"""
load_from_file(file_name) -> data
Load an image from a file, and rescale it if it does not fit the input data format
Optionnally, data augmentation is performed.
**Parameters**
file_name: path
The name of the (image) file to load.
**Returns**
data: numpy array
The image data
"""
d
=
bob
.
io
.
base
.
load
(
file_name
)
# Applying the data augmentation
...
...
@@ -132,6 +147,22 @@ class DrGanDisk(Base):
def
get_batch
(
self
):
"""
get_batch() -> selected_data, selected_pose_labels, selected_id_labels
This function selects and returns data to be used in a minibatch iteration.
Note that returned data is randomly selected in the training set
**Returns**
selected_data:
The face images.
selected_pose_labels:
The pose labels
selected_id_labels:
The id labels
"""
# Shuffling samples
indexes
=
numpy
.
array
(
range
(
self
.
data
.
shape
[
0
]))
...
...
@@ -155,13 +186,30 @@ class DrGanDisk(Base):
def
get_batch_epoch
(
self
):
"""
get_batch_epoch() -> selected_data, selected_pose_labels, selected_id_labels
This function selects and returns data to be used in a minibatch iterations.
Note that it works in epochs, i.e. all the training data should be seen
during one epoch, which consists in several minibatch iterations.
**Returns**
selected_data:
The face images.
selected_pose_labels:
The pose labels
selected_id_labels:
The id labels
"""
# this is done to rebuild the whole list (i.e. at the end of one epoch)
epoch_done
=
False
# returned mini-batch
selected_data
=
numpy
.
zeros
(
shape
=
self
.
shape
)
selected_labels
=
[]
selected_id_labels
=
[]
selected_pose_labels
=
[]
# if there is not enough available data to fill the current mini-batch
# add randomly some examples THAT ARE NOT STILL PRESENT in the dataset !
...
...
@@ -202,18 +250,22 @@ class DrGanDisk(Base):
selected_data
[
i
,
...]
=
self
.
normalizer
(
selected_data
[
i
,
...])
# label
selected_labels
.
append
(
self
.
labels
[
self
.
indexes
[
current_index
]])
selected_id_labels
.
append
(
self
.
id_labels
[
self
.
indexes
[
current_index
]])
selected_pose_labels
.
append
(
self
.
pose_labels
[
self
.
indexes
[
current_index
]])
# remove this example from the training set - used once in the epoch
new_indexes
=
numpy
.
delete
(
self
.
indexes
,
current_index
)
self
.
indexes
=
new_indexes
if
isinstance
(
selected_labels
,
list
):
selected_labels
=
numpy
.
array
(
selected_labels
)
if
isinstance
(
selected_id_labels
,
list
):
selected_id_labels
=
numpy
.
array
(
selected_id_labels
)
if
isinstance
(
selected_pose_labels
,
list
):
selected_pose_labels
=
numpy
.
array
(
selected_pose_labels
)
# rebuild whole randomly shuffled training dataset
if
epoch_done
:
self
.
indexes
=
numpy
.
array
(
range
(
self
.
data
.
shape
[
0
]))
numpy
.
random
.
shuffle
(
self
.
indexes
)
return
[
selected_data
.
astype
(
"
float32
"
),
selected_labels
.
astype
(
"
int64
"
),
epoch_done
]
return
[
selected_data
.
astype
(
"
float32
"
),
selected_
id_labels
.
astype
(
"
int64
"
),
selected_pose_
labels
.
astype
(
"
int64
"
),
epoch_done
]
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