LossContrastive: normalise features as per the paper

This commit is contained in:
Starbeamrainbowlabs 2022-10-26 16:52:56 +01:00
parent 843cc8dc7b
commit 48ae8a5c20
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -17,6 +17,10 @@ class LossContrastive(tf.keras.losses.Loss):
# rainfall = tf.reshape(rainfall, [self.batch_size, rainfall.shape[1]])
# water = tf.reshape(water, [self.batch_size, water.shape[1]])
# normalise features
rainfall = rainfall / tf.math.l2_normalize(rainfall, axis=1)
rainfall = rainfall / tf.math.l2_normalize(rainfall, axis=1)
# logits = tf.linalg.matmul(rainfall, tf.transpose(water)) * tf.clip_by_value(tf.math.exp(self.weight_temperature), 0, 100)
logits = tf.linalg.matmul(rainfall, tf.transpose(water)) * tf.math.exp(self.weight_temperature)