Updating cosine similarity loss.

- Changed CosineProximity to CosineSimilarity in v2
- Added `tf.keras.losses.cosine_similarity` to the namespaces. Keeping the existing v1 namespaces.
- Removed the negate sign from cosine similarity.

PiperOrigin-RevId: 234885212
This commit is contained in:
Pavithra Vijay 2019-02-20 15:47:23 -08:00 committed by TensorFlower Gardener
parent 8e03991534
commit 6513629c35
18 changed files with 110 additions and 117 deletions

View File

@ -22,7 +22,7 @@ from __future__ import print_function
from tensorflow.python.keras.losses import binary_crossentropy
from tensorflow.python.keras.losses import categorical_crossentropy
from tensorflow.python.keras.losses import categorical_hinge
from tensorflow.python.keras.losses import cosine_proximity
from tensorflow.python.keras.losses import cosine_similarity
from tensorflow.python.keras.losses import hinge
from tensorflow.python.keras.losses import kullback_leibler_divergence
from tensorflow.python.keras.losses import logcosh

View File

@ -23,7 +23,7 @@ from tensorflow.python.keras.metrics import binary_accuracy
from tensorflow.python.keras.metrics import binary_crossentropy
from tensorflow.python.keras.metrics import categorical_accuracy
from tensorflow.python.keras.metrics import categorical_crossentropy
from tensorflow.python.keras.metrics import cosine_proximity
from tensorflow.python.keras.metrics import cosine_similarity
from tensorflow.python.keras.metrics import hinge
from tensorflow.python.keras.metrics import kullback_leibler_divergence
from tensorflow.python.keras.metrics import mean_absolute_error

View File

@ -943,38 +943,53 @@ def poisson(y_true, y_pred):
return K.mean(y_pred - y_true * math_ops.log(y_pred + K.epsilon()), axis=-1)
@keras_export('keras.metrics.cosine_proximity',
'keras.metrics.cosine',
'keras.losses.cosine_proximity',
'keras.losses.cosine')
# Retaining the legacy namespaces: 'cosine_proximity' and 'cosine'.
# TODO(psv): Change name of this function to `cosine_similarity` after fixing
# estimator test.
@keras_export(
'keras.losses.cosine_similarity',
v1=[
'keras.metrics.cosine_proximity',
'keras.metrics.cosine',
'keras.losses.cosine_proximity',
'keras.losses.cosine',
'keras.losses.cosine_similarity',
])
def cosine_proximity(y_true, y_pred, axis=-1):
"""Computes the cosine similarity between labels and predictions."""
y_true = nn.l2_normalize(y_true, axis=axis)
y_pred = nn.l2_normalize(y_pred, axis=axis)
return -math_ops.reduce_sum(y_true * y_pred, axis=axis)
return math_ops.reduce_sum(y_true * y_pred, axis=axis)
@keras_export('keras.losses.CosineProximity')
class CosineProximity(Loss):
"""Computes the cosine proximity between `y_true` and `y_pred`.
@keras_export('keras.losses.CosineSimilarity')
class CosineSimilarity(LossFunctionWrapper):
"""Computes the cosine similarity between `y_true` and `y_pred`.
Usage:
```python
cosine_loss = tf.keras.losses.CosineProximity()
loss = cosine_loss([0., 1., 1.], [1., 0., 1.])
print('Loss: ', loss.numpy()) # Loss: -0.5
cosine_loss = tf.keras.losses.CosineSimilarity(axis=1)
loss = cosine_loss([[0., 1.], [1., 1.]], [[1., 0.], [1., 1.]])
# l2_norm(y_true) = [[0., 1.], [1./1.414], 1./1.414]]]
# l2_norm(y_pred) = [[1., 0.], [1./1.414], 1./1.414]]]
# l2_norm(y_true) . l2_norm(y_pred) = [[0., 0.], [0.5, 0.5]]
# loss = mean(sum(l2_norm(y_true) . l2_norm(y_pred), axis=1))
= ((0. + 0.) + (0.5 + 0.5)) / 2
print('Loss: ', loss.numpy()) # Loss: 0.5
```
Usage with tf.keras API:
```python
model = tf.keras.Model(inputs, outputs)
model.compile('sgd', loss=tf.keras.losses.CosineProximity())
model.compile('sgd', loss=tf.keras.losses.CosineSimilarity(axis=1))
```
Args:
axis: (Optional) Defaults to -1. The dimension along which the cosine
proximity is computed.
similarity is computed.
reduction: (Optional) Type of `tf.keras.losses.Reduction` to apply to loss.
Default value is `SUM_OVER_BATCH_SIZE`.
name: Optional name for the op.
@ -983,23 +998,9 @@ class CosineProximity(Loss):
def __init__(self,
axis=-1,
reduction=losses_utils.ReductionV2.SUM_OVER_BATCH_SIZE,
name=None):
super(CosineProximity, self).__init__(reduction=reduction, name=name)
self.axis = axis
def call(self, y_true, y_pred):
"""Calculates the cosine proximity loss.
Args:
y_true: Ground truth values.
y_pred: The predicted values.
Returns:
Cosine distance loss.
"""
y_pred = ops.convert_to_tensor(y_pred)
y_true = math_ops.cast(y_true, y_pred.dtype)
return cosine_proximity(y_true, y_pred, axis=self.axis)
name='cosine_similarity'):
super(CosineSimilarity, self).__init__(
cosine_similarity, reduction=reduction, name=name, axis=axis)
# Aliases.
@ -1009,7 +1010,7 @@ mae = MAE = mean_absolute_error
mape = MAPE = mean_absolute_percentage_error
msle = MSLE = mean_squared_logarithmic_error
kld = KLD = kullback_leibler_divergence
cosine = cosine_proximity
cosine_similarity = cosine_proximity
def is_categorical_crossentropy(loss):

View File

@ -45,7 +45,7 @@ ALL_LOSSES = [keras.losses.mean_squared_error,
keras.losses.binary_crossentropy,
keras.losses.kullback_leibler_divergence,
keras.losses.poisson,
keras.losses.cosine_proximity,
keras.losses.cosine_similarity,
keras.losses.logcosh,
keras.losses.categorical_hinge]
@ -501,7 +501,7 @@ class MeanSquaredLogarithmicErrorTest(test.TestCase):
@test_util.run_all_in_graph_and_eager_modes
class CosineProximityTest(test.TestCase):
class CosineSimilarityTest(test.TestCase):
def l2_norm(self, x, axis):
epsilon = 1e-12
@ -515,28 +515,27 @@ class CosineProximityTest(test.TestCase):
y_true = self.l2_norm(self.np_y_true, axis)
y_pred = self.l2_norm(self.np_y_pred, axis)
self.expected_loss = -np.sum(np.multiply(y_true, y_pred), axis=(axis,))
self.expected_loss = np.sum(np.multiply(y_true, y_pred), axis=(axis,))
self.y_true = constant_op.constant(self.np_y_true)
self.y_pred = constant_op.constant(self.np_y_pred)
def test_config(self):
cosine_obj = keras.losses.CosineProximity(
cosine_obj = keras.losses.CosineSimilarity(
axis=2, reduction=losses_utils.ReductionV2.SUM, name='cosine_loss')
self.assertEqual(cosine_obj.name, 'cosine_loss')
self.assertEqual(cosine_obj.reduction, losses_utils.ReductionV2.SUM)
self.assertEqual(cosine_obj.axis, 2)
def test_unweighted(self):
self.setup()
cosine_obj = keras.losses.CosineProximity()
cosine_obj = keras.losses.CosineSimilarity()
loss = cosine_obj(self.y_true, self.y_pred)
expected_loss = np.mean(self.expected_loss)
self.assertAlmostEqual(self.evaluate(loss), expected_loss, 3)
def test_scalar_weighted(self):
self.setup()
cosine_obj = keras.losses.CosineProximity()
cosine_obj = keras.losses.CosineSimilarity()
sample_weight = 2.3
loss = cosine_obj(self.y_true, self.y_pred, sample_weight=sample_weight)
expected_loss = np.mean(self.expected_loss * sample_weight)
@ -544,7 +543,7 @@ class CosineProximityTest(test.TestCase):
def test_sample_weighted(self):
self.setup()
cosine_obj = keras.losses.CosineProximity()
cosine_obj = keras.losses.CosineSimilarity()
sample_weight = np.asarray([1.2, 3.4])
loss = cosine_obj(
self.y_true,
@ -555,14 +554,14 @@ class CosineProximityTest(test.TestCase):
def test_timestep_weighted(self):
self.setup()
cosine_obj = keras.losses.CosineProximity()
cosine_obj = keras.losses.CosineSimilarity()
np_y_true = self.np_y_true.reshape((2, 3, 1))
np_y_pred = self.np_y_pred.reshape((2, 3, 1))
sample_weight = np.asarray([3, 6, 5, 0, 4, 2]).reshape((2, 3))
y_true = self.l2_norm(np_y_true, 2)
y_pred = self.l2_norm(np_y_pred, 2)
expected_loss = -np.sum(np.multiply(y_true, y_pred), axis=(2,))
expected_loss = np.sum(np.multiply(y_true, y_pred), axis=(2,))
y_true = constant_op.constant(np_y_true)
y_pred = constant_op.constant(np_y_pred)
@ -574,13 +573,13 @@ class CosineProximityTest(test.TestCase):
def test_zero_weighted(self):
self.setup()
cosine_obj = keras.losses.CosineProximity()
cosine_obj = keras.losses.CosineSimilarity()
loss = cosine_obj(self.y_true, self.y_pred, sample_weight=0)
self.assertAlmostEqual(self.evaluate(loss), 0., 3)
def test_axis(self):
self.setup(axis=1)
cosine_obj = keras.losses.CosineProximity(axis=1)
cosine_obj = keras.losses.CosineSimilarity(axis=1)
loss = cosine_obj(self.y_true, self.y_pred)
expected_loss = np.mean(self.expected_loss)
self.assertAlmostEqual(self.evaluate(loss), expected_loss, 3)

View File

@ -34,7 +34,7 @@ from tensorflow.python.keras.engine.base_layer import Layer
from tensorflow.python.keras.losses import binary_crossentropy
from tensorflow.python.keras.losses import categorical_crossentropy
from tensorflow.python.keras.losses import categorical_hinge
from tensorflow.python.keras.losses import cosine_proximity
from tensorflow.python.keras.losses import cosine_similarity
from tensorflow.python.keras.losses import hinge
from tensorflow.python.keras.losses import kullback_leibler_divergence
from tensorflow.python.keras.losses import logcosh
@ -1818,21 +1818,30 @@ class AUC(Metric):
return dict(list(base_config.items()) + list(config.items()))
@keras_export('keras.metrics.CosineProximity')
class CosineProximity(MeanMetricWrapper):
"""Computes the cosine distance between the labels and predictions.
@keras_export('keras.metrics.CosineSimilarity')
class CosineSimilarity(MeanMetricWrapper):
"""Computes the cosine similarity between the labels and predictions.
cosine similarity = (a . b) / ||a|| ||b||
(https://en.wikipedia.org/wiki/Cosine_similarity)
For example, if `y_true` is [0, 1, 1], and `y_pred` is [1, 0, 1], the cosine
proximity is -0.5.
similarity is 0.5.
This metric keeps the average cosine distance between `predictions` and
This metric keeps the average cosine similarity between `predictions` and
`labels` over a stream of data.
Usage:
```python
m = tf.keras.metrics.CosineProximity()
m.update_state([0, 1, 1], [1, 0, 1])
print('Final result: ', m.result().numpy()) # Final result: -0.5
m = tf.keras.metrics.CosineSimilarity(axis=1)
m.update_state([[0., 1.], [1., 1.]], [[1., 0.], [1., 1.]])
# l2_norm(y_true) = [[0., 1.], [1./1.414], 1./1.414]]]
# l2_norm(y_pred) = [[1., 0.], [1./1.414], 1./1.414]]]
# l2_norm(y_true) . l2_norm(y_pred) = [[0., 0.], [0.5, 0.5]]
# result = mean(sum(l2_norm(y_true) . l2_norm(y_pred), axis=1))
= ((0. + 0.) + (0.5 + 0.5)) / 2
print('Final result: ', m.result().numpy()) # Final result: 0.5
```
Usage with tf.keras API:
@ -1842,20 +1851,21 @@ class CosineProximity(MeanMetricWrapper):
model.compile(
'sgd',
loss='mse',
metrics=[tf.keras.metrics.CosineProximity()])
metrics=[tf.keras.metrics.CosineSimilarity(axis=1)])
```
"""
def __init__(self, name='cosine_proximity', dtype=None, axis=-1):
"""Creates a `CosineProximity` instance.
def __init__(self, name='cosine_similarity', dtype=None, axis=-1):
"""Creates a `CosineSimilarity` instance.
Args:
name: (Optional) string name of the metric instance.
dtype: (Optional) data type of the metric result.
axis: (Optional) Defaults to -1. The dimension along which the cosine
proximity is computed.
similarity is computed.
"""
super(CosineProximity, self).__init__(cosine, name, dtype=dtype, axis=axis)
super(CosineSimilarity, self).__init__(
cosine_similarity, name, dtype=dtype, axis=axis)
@keras_export('keras.metrics.MeanAbsoluteError')
@ -2744,7 +2754,7 @@ mse = MSE = mean_squared_error
mae = MAE = mean_absolute_error
mape = MAPE = mean_absolute_percentage_error
msle = MSLE = mean_squared_logarithmic_error
cosine = cosine_proximity
cosine_proximity = cosine_similarity
def clone_metric(metric):

View File

@ -453,7 +453,7 @@ class KerasAccuracyTest(test.TestCase):
@test_util.run_all_in_graph_and_eager_modes
class CosineProximityTest(test.TestCase):
class CosineSimilarityTest(test.TestCase):
def l2_norm(self, x, axis):
epsilon = 1e-12
@ -467,25 +467,25 @@ class CosineProximityTest(test.TestCase):
y_true = self.l2_norm(self.np_y_true, axis)
y_pred = self.l2_norm(self.np_y_pred, axis)
self.expected_loss = -np.sum(np.multiply(y_true, y_pred), axis=(axis,))
self.expected_loss = np.sum(np.multiply(y_true, y_pred), axis=(axis,))
self.y_true = constant_op.constant(self.np_y_true)
self.y_pred = constant_op.constant(self.np_y_pred)
def test_config(self):
cosine_obj = metrics.CosineProximity(
cosine_obj = metrics.CosineSimilarity(
axis=2, name='my_cos', dtype=dtypes.int32)
self.assertEqual(cosine_obj.name, 'my_cos')
self.assertEqual(cosine_obj._dtype, dtypes.int32)
# Check save and restore config
cosine_obj2 = metrics.CosineProximity.from_config(cosine_obj.get_config())
cosine_obj2 = metrics.CosineSimilarity.from_config(cosine_obj.get_config())
self.assertEqual(cosine_obj2.name, 'my_cos')
self.assertEqual(cosine_obj2._dtype, dtypes.int32)
def test_unweighted(self):
self.setup()
cosine_obj = metrics.CosineProximity()
cosine_obj = metrics.CosineSimilarity()
self.evaluate(variables.variables_initializer(cosine_obj.variables))
loss = cosine_obj(self.y_true, self.y_pred)
expected_loss = np.mean(self.expected_loss)
@ -493,7 +493,7 @@ class CosineProximityTest(test.TestCase):
def test_weighted(self):
self.setup()
cosine_obj = metrics.CosineProximity()
cosine_obj = metrics.CosineSimilarity()
self.evaluate(variables.variables_initializer(cosine_obj.variables))
sample_weight = np.asarray([1.2, 3.4])
loss = cosine_obj(
@ -506,7 +506,7 @@ class CosineProximityTest(test.TestCase):
def test_axis(self):
self.setup(axis=1)
cosine_obj = metrics.CosineProximity(axis=1)
cosine_obj = metrics.CosineSimilarity(axis=1)
self.evaluate(variables.variables_initializer(cosine_obj.variables))
loss = cosine_obj(self.y_true, self.y_pred)
expected_loss = np.mean(self.expected_loss)

View File

@ -1,11 +1,12 @@
path: "tensorflow.losses.CosineProximity"
path: "tensorflow.keras.losses.CosineSimilarity"
tf_class {
is_instance: "<class \'tensorflow.python.keras.losses.CosineProximity\'>"
is_instance: "<class \'tensorflow.python.keras.losses.CosineSimilarity\'>"
is_instance: "<class \'tensorflow.python.keras.losses.LossFunctionWrapper\'>"
is_instance: "<class \'tensorflow.python.keras.losses.Loss\'>"
is_instance: "<type \'object\'>"
member_method {
name: "__init__"
argspec: "args=[\'self\', \'axis\', \'reduction\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'sum_over_batch_size\', \'None\'], "
argspec: "args=[\'self\', \'axis\', \'reduction\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'sum_over_batch_size\', \'cosine_similarity\'], "
}
member_method {
name: "call"

View File

@ -13,7 +13,7 @@ tf_module {
mtype: "<type \'type\'>"
}
member {
name: "CosineProximity"
name: "CosineSimilarity"
mtype: "<type \'type\'>"
}
member {
@ -108,6 +108,10 @@ tf_module {
name: "cosine_proximity"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {
name: "cosine_similarity"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {
name: "deserialize"
argspec: "args=[\'name\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], "

View File

@ -1,6 +1,6 @@
path: "tensorflow.keras.metrics.CosineProximity"
path: "tensorflow.keras.metrics.CosineSimilarity"
tf_class {
is_instance: "<class \'tensorflow.python.keras.metrics.CosineProximity\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.CosineSimilarity\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.MeanMetricWrapper\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.Mean\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.Reduce\'>"
@ -90,7 +90,7 @@ tf_class {
}
member_method {
name: "__init__"
argspec: "args=[\'self\', \'name\', \'dtype\', \'axis\'], varargs=None, keywords=None, defaults=[\'cosine_proximity\', \'None\', \'-1\'], "
argspec: "args=[\'self\', \'name\', \'dtype\', \'axis\'], varargs=None, keywords=None, defaults=[\'cosine_similarity\', \'None\', \'-1\'], "
}
member_method {
name: "add_loss"

View File

@ -29,7 +29,7 @@ tf_module {
mtype: "<type \'type\'>"
}
member {
name: "CosineProximity"
name: "CosineSimilarity"
mtype: "<type \'type\'>"
}
member {

View File

@ -1,11 +1,12 @@
path: "tensorflow.keras.losses.CosineProximity"
path: "tensorflow.keras.losses.CosineSimilarity"
tf_class {
is_instance: "<class \'tensorflow.python.keras.losses.CosineProximity\'>"
is_instance: "<class \'tensorflow.python.keras.losses.CosineSimilarity\'>"
is_instance: "<class \'tensorflow.python.keras.losses.LossFunctionWrapper\'>"
is_instance: "<class \'tensorflow.python.keras.losses.Loss\'>"
is_instance: "<type \'object\'>"
member_method {
name: "__init__"
argspec: "args=[\'self\', \'axis\', \'reduction\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'sum_over_batch_size\', \'None\'], "
argspec: "args=[\'self\', \'axis\', \'reduction\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'sum_over_batch_size\', \'cosine_similarity\'], "
}
member_method {
name: "call"

View File

@ -13,7 +13,7 @@ tf_module {
mtype: "<type \'type\'>"
}
member {
name: "CosineProximity"
name: "CosineSimilarity"
mtype: "<type \'type\'>"
}
member {
@ -105,11 +105,7 @@ tf_module {
argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "cosine"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {
name: "cosine_proximity"
name: "cosine_similarity"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {

View File

@ -1,6 +1,6 @@
path: "tensorflow.keras.metrics.CosineProximity"
path: "tensorflow.keras.metrics.CosineSimilarity"
tf_class {
is_instance: "<class \'tensorflow.python.keras.metrics.CosineProximity\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.CosineSimilarity\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.MeanMetricWrapper\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.Mean\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.Reduce\'>"
@ -90,7 +90,7 @@ tf_class {
}
member_method {
name: "__init__"
argspec: "args=[\'self\', \'name\', \'dtype\', \'axis\'], varargs=None, keywords=None, defaults=[\'cosine_proximity\', \'None\', \'-1\'], "
argspec: "args=[\'self\', \'name\', \'dtype\', \'axis\'], varargs=None, keywords=None, defaults=[\'cosine_similarity\', \'None\', \'-1\'], "
}
member_method {
name: "add_loss"

View File

@ -29,7 +29,7 @@ tf_module {
mtype: "<type \'type\'>"
}
member {
name: "CosineProximity"
name: "CosineSimilarity"
mtype: "<type \'type\'>"
}
member {
@ -180,14 +180,6 @@ tf_module {
name: "categorical_crossentropy"
argspec: "args=[\'y_true\', \'y_pred\', \'from_logits\', \'label_smoothing\'], varargs=None, keywords=None, defaults=[\'False\', \'0\'], "
}
member_method {
name: "cosine"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {
name: "cosine_proximity"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {
name: "deserialize"
argspec: "args=[\'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], "

View File

@ -1,11 +1,12 @@
path: "tensorflow.keras.losses.CosineProximity"
path: "tensorflow.losses.CosineSimilarity"
tf_class {
is_instance: "<class \'tensorflow.python.keras.losses.CosineProximity\'>"
is_instance: "<class \'tensorflow.python.keras.losses.CosineSimilarity\'>"
is_instance: "<class \'tensorflow.python.keras.losses.LossFunctionWrapper\'>"
is_instance: "<class \'tensorflow.python.keras.losses.Loss\'>"
is_instance: "<type \'object\'>"
member_method {
name: "__init__"
argspec: "args=[\'self\', \'axis\', \'reduction\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'sum_over_batch_size\', \'None\'], "
argspec: "args=[\'self\', \'axis\', \'reduction\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'sum_over_batch_size\', \'cosine_similarity\'], "
}
member_method {
name: "call"

View File

@ -13,7 +13,7 @@ tf_module {
mtype: "<type \'type\'>"
}
member {
name: "CosineProximity"
name: "CosineSimilarity"
mtype: "<type \'type\'>"
}
member {
@ -105,11 +105,7 @@ tf_module {
argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "cosine"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {
name: "cosine_proximity"
name: "cosine_similarity"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {

View File

@ -1,6 +1,6 @@
path: "tensorflow.metrics.CosineProximity"
path: "tensorflow.metrics.CosineSimilarity"
tf_class {
is_instance: "<class \'tensorflow.python.keras.metrics.CosineProximity\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.CosineSimilarity\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.MeanMetricWrapper\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.Mean\'>"
is_instance: "<class \'tensorflow.python.keras.metrics.Reduce\'>"
@ -90,7 +90,7 @@ tf_class {
}
member_method {
name: "__init__"
argspec: "args=[\'self\', \'name\', \'dtype\', \'axis\'], varargs=None, keywords=None, defaults=[\'cosine_proximity\', \'None\', \'-1\'], "
argspec: "args=[\'self\', \'name\', \'dtype\', \'axis\'], varargs=None, keywords=None, defaults=[\'cosine_similarity\', \'None\', \'-1\'], "
}
member_method {
name: "add_loss"

View File

@ -29,7 +29,7 @@ tf_module {
mtype: "<type \'type\'>"
}
member {
name: "CosineProximity"
name: "CosineSimilarity"
mtype: "<type \'type\'>"
}
member {
@ -180,14 +180,6 @@ tf_module {
name: "categorical_crossentropy"
argspec: "args=[\'y_true\', \'y_pred\', \'from_logits\', \'label_smoothing\'], varargs=None, keywords=None, defaults=[\'False\', \'0\'], "
}
member_method {
name: "cosine"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {
name: "cosine_proximity"
argspec: "args=[\'y_true\', \'y_pred\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], "
}
member_method {
name: "deserialize"
argspec: "args=[\'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], "