Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.learn.tensorflow
Commits
95398b3b
Commit
95398b3b
authored
Nov 17, 2016
by
Tiago de Freitas Pereira
Browse files
Fixed issue with feature normalization
parent
c5f684f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/learn/tensorflow/datashuffler/TripletWithFastSelectionDisk.py
View file @
95398b3b
...
...
@@ -106,13 +106,9 @@ class TripletWithFastSelectionDisk(Triplet, Disk, OnLineSampling):
for
i
in
range
(
self
.
shape
[
0
]):
file_name_a
,
file_name_p
,
file_name_n
=
self
.
get_one_triplet
(
self
.
data
,
self
.
labels
)
sample_a
[
i
,
...]
=
self
.
load_from_file
(
str
(
file_name_a
))
sample_p
[
i
,
...]
=
self
.
load_from_file
(
str
(
file_name_p
))
sample_n
[
i
,
...]
=
self
.
load_from_file
(
str
(
file_name_n
))
sample_a
=
self
.
normalize_sample
(
sample_a
)
sample_p
=
self
.
normalize_sample
(
sample_p
)
sample_n
=
self
.
normalize_sample
(
sample_n
)
sample_a
[
i
,
...]
=
self
.
normalize_sample
(
self
.
load_from_file
(
str
(
file_name_a
)))
sample_p
[
i
,
...]
=
self
.
normalize_sample
(
self
.
load_from_file
(
str
(
file_name_p
)))
sample_n
[
i
,
...]
=
self
.
normalize_sample
(
self
.
load_from_file
(
str
(
file_name_n
)))
return
[
sample_a
,
sample_p
,
sample_n
]
...
...
@@ -180,9 +176,8 @@ class TripletWithFastSelectionDisk(Triplet, Disk, OnLineSampling):
indexes
=
numpy
.
where
(
self
.
labels
==
l
)[
0
]
numpy
.
random
.
shuffle
(
indexes
)
file_name
=
self
.
data
[
indexes
[
0
],
...]
samples_p
[
i
,
...]
=
self
.
load_from_file
(
str
(
file_name
))
samples_p
[
i
,
...]
=
self
.
normalize_sample
(
self
.
load_from_file
(
str
(
file_name
))
)
samples_p
=
self
.
normalize_sample
(
samples_p
)
embedding_p
=
self
.
project
(
samples_p
)
# Computing the distances
...
...
@@ -212,8 +207,7 @@ class TripletWithFastSelectionDisk(Triplet, Disk, OnLineSampling):
samples_n
=
numpy
.
zeros
(
shape
=
self
.
shape
,
dtype
=
'float32'
)
for
i
in
range
(
shape
[
0
]):
file_name
=
self
.
data
[
indexes
[
i
],
...]
temp_samples_n
[
i
,
...]
=
self
.
load_from_file
(
str
(
file_name
))
temp_samples_n
=
self
.
normalize_sample
(
temp_samples_n
)
temp_samples_n
[
i
,
...]
=
self
.
normalize_sample
(
self
.
load_from_file
(
str
(
file_name
)))
# Computing all the embeddings
embedding_temp_n
=
self
.
project
(
temp_samples_n
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment