Skip to content

Commit 41f4d3d

Browse files
authored
Fix typo "constrastive"
1 parent 24d8429 commit 41f4d3d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

examples/vision/siamese_contrastive.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
epochs = 10
3939
batch_size = 16
40-
margin = 1 # Margin for constrastive loss.
40+
margin = 1 # Margin for contrastive loss.
4141

4242
"""
4343
## Load the MNIST dataset
@@ -301,33 +301,33 @@ def euclidean_distance(vects):
301301

302302

303303
"""
304-
## Define the constrastive Loss
304+
## Define the contrastive Loss
305305
"""
306306

307307

308308
def loss(margin=1):
309-
"""Provides 'constrastive_loss' an enclosing scope with variable 'margin'.
309+
"""Provides 'contrastive_loss' an enclosing scope with variable 'margin'.
310310
311311
Arguments:
312312
margin: Integer, defines the baseline for distance for which pairs
313313
should be classified as dissimilar. - (default is 1).
314314
315315
Returns:
316-
'constrastive_loss' function with data ('margin') attached.
316+
'contrastive_loss' function with data ('margin') attached.
317317
"""
318318

319319
# Contrastive loss = mean( (1-true_value) * square(prediction) +
320320
# true_value * square( max(margin-prediction, 0) ))
321321
def contrastive_loss(y_true, y_pred):
322-
"""Calculates the constrastive loss.
322+
"""Calculates the contrastive loss.
323323
324324
Arguments:
325325
y_true: List of labels, each label is of type float32.
326326
y_pred: List of predictions of same length as of y_true,
327327
each label is of type float32.
328328
329329
Returns:
330-
A tensor containing constrastive loss as floating point value.
330+
A tensor containing contrastive loss as floating point value.
331331
"""
332332

333333
square_pred = tf.math.square(y_pred)
@@ -389,8 +389,8 @@ def plt_metric(history, metric, title, has_valid=True):
389389
# Plot the accuracy
390390
plt_metric(history=history.history, metric="accuracy", title="Model accuracy")
391391

392-
# Plot the constrastive loss
393-
plt_metric(history=history.history, metric="loss", title="Constrastive Loss")
392+
# Plot the contrastive loss
393+
plt_metric(history=history.history, metric="loss", title="Contrastive Loss")
394394

395395
"""
396396
## Evaluate the model

0 commit comments

Comments
 (0)