Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
ae80945e
Commit
ae80945e
authored
Mar 20, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix build
parent
2488a34f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
examples/SimilarityLearning/mnist-embeddings.py
examples/SimilarityLearning/mnist-embeddings.py
+7
-7
No files found.
examples/SimilarityLearning/mnist-embeddings.py
View file @
ae80945e
...
...
@@ -243,11 +243,12 @@ class SiameseModel(EmbeddingModel):
def
build_graph
(
self
,
x
,
y
,
label
):
# embed them
single_input
=
x
x
,
y
=
self
.
embed
([
x
,
y
])
# tag the embedding of 'input' with name 'emb', just for inference later on
with
tf
.
variable_scope
(
tf
.
get_variable_scope
(),
reuse
=
True
):
tf
.
identity
(
self
.
embed
(
x
),
name
=
"emb"
)
tf
.
identity
(
self
.
embed
(
single_input
),
name
=
"emb"
)
# compute the actual loss
cost
,
pos_dist
,
neg_dist
=
contrastive_loss
(
x
,
y
,
label
,
5.
,
extra
=
True
,
scope
=
"loss"
)
...
...
@@ -260,10 +261,11 @@ class SiameseModel(EmbeddingModel):
class
CosineModel
(
SiameseModel
):
def
build_graph
(
self
,
x
,
y
,
label
):
single_input
=
x
x
,
y
=
self
.
embed
([
x
,
y
])
with
tf
.
variable_scope
(
tf
.
get_variable_scope
(),
reuse
=
True
):
tf
.
identity
(
self
.
embed
(
x
),
name
=
"emb"
)
tf
.
identity
(
self
.
embed
(
single_input
),
name
=
"emb"
)
cost
=
siamese_cosine_loss
(
x
,
y
,
label
,
scope
=
"loss"
)
cost
=
tf
.
identity
(
cost
,
name
=
"cost"
)
...
...
@@ -287,10 +289,11 @@ class TripletModel(EmbeddingModel):
return
triplet_loss
(
a
,
p
,
n
,
5.
,
extra
=
True
,
scope
=
"loss"
)
def
build_graph
(
self
,
a
,
p
,
n
):
single_input
=
a
a
,
p
,
n
=
self
.
embed
([
a
,
p
,
n
])
with
tf
.
variable_scope
(
tf
.
get_variable_scope
(),
reuse
=
True
):
tf
.
identity
(
self
.
embed
(
a
),
name
=
"emb"
)
tf
.
identity
(
self
.
embed
(
single_input
),
name
=
"emb"
)
cost
,
pos_dist
,
neg_dist
=
self
.
loss
(
a
,
p
,
n
)
...
...
@@ -318,10 +321,7 @@ class CenterModel(EmbeddingModel):
def
build_graph
(
self
,
x
,
label
):
# embed them
x
=
self
.
embed
(
x
)
# tag the embedding of 'input' with name 'emb', just for inference later on
with
tf
.
variable_scope
(
tf
.
get_variable_scope
(),
reuse
=
True
):
tf
.
identity
(
self
.
embed
(
x
),
name
=
"emb"
)
x
=
tf
.
identity
(
x
,
name
=
'emb'
)
# compute the embedding loss
emb_cost
=
center_loss
(
x
,
label
,
10
,
0.01
)
...
...
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