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
8ecba2f8
Commit
8ecba2f8
authored
Sep 19, 2017
by
Tiago de Freitas Pereira
Browse files
L2 normalize the embeddings
parent
1952c2f5
Pipeline
#12296
failed with stages
in 4 minutes and 31 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/learn/tensorflow/loss/ContrastiveLoss.py
View file @
8ecba2f8
...
...
@@ -41,6 +41,10 @@ class ContrastiveLoss(BaseLoss):
def
__call__
(
self
,
label
,
left_feature
,
right_feature
):
with
tf
.
name_scope
(
"contrastive_loss"
):
label
=
tf
.
to_float
(
label
)
left_feature
=
tf
.
nn
.
l2_normalize
(
left_feature
,
1
)
right_feature
=
tf
.
nn
.
l2_normalize
(
right_feature
,
1
)
one
=
tf
.
constant
(
1.0
)
d
=
compute_euclidean_distance
(
left_feature
,
right_feature
)
...
...
Write
Preview
Markdown
is supported
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