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
1952c2f5
Commit
1952c2f5
authored
7 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
New test cases
parent
5a60ec56
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!13
Updates
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/learn/tensorflow/test/test_cnn_pretrained_model.py
+2
-1
2 additions, 1 deletion
bob/learn/tensorflow/test/test_cnn_pretrained_model.py
bob/learn/tensorflow/test/test_cnn_scratch.py
+24
-3
24 additions, 3 deletions
bob/learn/tensorflow/test/test_cnn_scratch.py
with
26 additions
and
4 deletions
bob/learn/tensorflow/test/test_cnn_pretrained_model.py
+
2
−
1
View file @
1952c2f5
...
...
@@ -256,4 +256,5 @@ def test_siamese_cnn_pretrained():
del
trainer
tf
.
reset_default_graph
()
assert
len
(
tf
.
global_variables
())
==
0
assert
len
(
tf
.
global_variables
())
==
0
This diff is collapsed.
Click to expand it.
bob/learn/tensorflow/test/test_cnn_scratch.py
+
24
−
3
View file @
1952c2f5
...
...
@@ -28,7 +28,10 @@ slim = tf.contrib.slim
def
scratch_network
(
train_data_shuffler
,
reuse
=
False
):
inputs
=
train_data_shuffler
(
"
data
"
,
from_queue
=
False
)
if
isinstance
(
train_data_shuffler
,
tf
.
Tensor
):
inputs
=
train_data_shuffler
else
:
inputs
=
train_data_shuffler
(
"
data
"
,
from_queue
=
False
)
# Creating a random network
initializer
=
tf
.
contrib
.
layers
.
xavier_initializer
(
seed
=
seed
)
...
...
@@ -150,7 +153,7 @@ def test_cnn_trainer_scratch_tfrecord():
graph
=
scratch_network
(
train_data_shuffler
)
validation_graph
=
scratch_network
(
validation_data_shuffler
,
reuse
=
True
)
# Setting the placeholders
# Loss for the softmax
loss
=
MeanSoftMaxLoss
()
...
...
@@ -174,9 +177,27 @@ def test_cnn_trainer_scratch_tfrecord():
trainer
.
train
()
os
.
remove
(
tfrecords_filename
)
os
.
remove
(
tfrecords_filename_val
)
os
.
remove
(
tfrecords_filename_val
)
assert
True
tf
.
reset_default_graph
()
del
trainer
assert
len
(
tf
.
global_variables
())
==
0
# Inference. TODO: Wrap this in a package
file_name
=
os
.
path
.
join
(
directory
,
"
model.ckp.meta
"
)
images
=
tf
.
placeholder
(
tf
.
float32
,
shape
=
(
None
,
28
,
28
,
1
))
graph
=
scratch_network
(
images
,
reuse
=
False
)
session
=
tf
.
Session
()
session
.
run
(
tf
.
global_variables_initializer
())
saver
=
tf
.
train
.
import_meta_graph
(
file_name
,
clear_devices
=
True
)
saver
.
restore
(
session
,
tf
.
train
.
latest_checkpoint
(
os
.
path
.
dirname
(
"
./temp/cnn_scratch/
"
)))
data
=
numpy
.
random
.
rand
(
2
,
28
,
28
,
1
).
astype
(
"
float32
"
)
assert
session
.
run
(
graph
,
feed_dict
=
{
images
:
data
}).
shape
==
(
2
,
10
)
tf
.
reset_default_graph
()
shutil
.
rmtree
(
directory
)
assert
len
(
tf
.
global_variables
())
==
0
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