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
0e808a8e
There was a problem fetching the pipeline summary.
Commit
0e808a8e
authored
7 years ago
by
Tiago Pereira
Browse files
Options
Downloads
Patches
Plain Diff
[architecture] Created a test case for the inception net issue
#17
[architecture] Created a test case for the inception net issue
#17
parent
74c00208
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/test/test_inception.py
+91
-0
91 additions, 0 deletions
bob/learn/tensorflow/test/test_inception.py
with
91 additions
and
0 deletions
bob/learn/tensorflow/test/test_inception.py
0 → 100644
+
91
−
0
View file @
0e808a8e
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# @date: Thu 13 Oct 2016 13:35 CEST
import
numpy
from
bob.learn.tensorflow.datashuffler
import
Disk
,
ScaleFactor
,
TripletDisk
from
bob.learn.tensorflow.loss
import
BaseLoss
,
ContrastiveLoss
,
TripletLoss
from
bob.learn.tensorflow.trainers
import
Trainer
,
SiameseTrainer
,
TripletTrainer
,
constant
import
shutil
import
tensorflow
as
tf
from
tensorflow.contrib.slim.python.slim.nets
import
inception
from
test_datashuffler
import
get_dummy_files
"""
Some unit tests for the datashuffler
"""
iterations
=
5
seed
=
10
def
test_inception_trainer
():
directory
=
"
./temp/inception
"
# Loading data
train_data
,
train_labels
=
get_dummy_files
()
batch_shape
=
[
None
,
224
,
224
,
3
]
train_data_shuffler
=
Disk
(
train_data
,
train_labels
,
input_shape
=
batch_shape
,
batch_size
=
2
)
# Loss for the softmax
loss
=
BaseLoss
(
tf
.
nn
.
sparse_softmax_cross_entropy_with_logits
,
tf
.
reduce_mean
)
# Creating inception model
inputs
=
train_data_shuffler
(
"
data
"
,
from_queue
=
False
)
graph
=
inception
.
inception_v1
(
inputs
)[
0
]
# One graph trainer
trainer
=
Trainer
(
train_data_shuffler
,
iterations
=
iterations
,
analizer
=
None
,
temp_dir
=
directory
)
trainer
.
create_network_from_scratch
(
graph
=
graph
,
loss
=
loss
,
learning_rate
=
constant
(
0.01
,
name
=
"
regular_lr
"
),
optimizer
=
tf
.
train
.
GradientDescentOptimizer
(
0.01
),
)
trainer
.
train
()
shutil
.
rmtree
(
directory
)
def
test_inception_triplet_trainer
():
directory
=
"
./temp/inception
"
# Loading data
train_data
,
train_labels
=
get_dummy_files
()
batch_shape
=
[
None
,
224
,
224
,
3
]
train_data_shuffler
=
TripletDisk
(
train_data
,
train_labels
,
input_shape
=
batch_shape
,
batch_size
=
2
)
# Loss for the softmax
loss
=
TripletLoss
()
# Creating inception model
inputs
=
train_data_shuffler
(
"
data
"
,
from_queue
=
False
)
graph
=
dict
()
graph
[
'
anchor
'
]
=
inception
.
inception_v1
(
inputs
[
'
anchor
'
])[
0
]
graph
[
'
positive
'
]
=
inception
.
inception_v1
(
inputs
[
'
positive
'
],
reuse
=
True
)[
0
]
graph
[
'
negative
'
]
=
inception
.
inception_v1
(
inputs
[
'
negative
'
],
reuse
=
True
)[
0
]
# One graph trainer
trainer
=
TripletTrainer
(
train_data_shuffler
,
iterations
=
iterations
,
analizer
=
None
,
temp_dir
=
directory
)
trainer
.
create_network_from_scratch
(
graph
=
graph
,
loss
=
loss
,
learning_rate
=
constant
(
0.01
,
name
=
"
regular_lr
"
),
optimizer
=
tf
.
train
.
GradientDescentOptimizer
(
0.01
)
)
trainer
.
train
()
shutil
.
rmtree
(
directory
)
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