### [pre-commit] fix pre-commit complaints

parent 06c797fe
Pipeline #49168 passed with stages
in 4 minutes and 45 seconds
 import math import numbers import numbers import tensorflow as tf import tensorflow as tf import math from tensorflow.keras.layers import BatchNormalization from tensorflow.keras.layers import Dense from tensorflow.keras.layers import Dropout from tensorflow.keras.layers import GlobalAvgPool2D def _check_input( def _check_input( ... @@ -164,7 +168,7 @@ def Normalize(mean, std=1.0, **kwargs): ... @@ -164,7 +168,7 @@ def Normalize(mean, std=1.0, **kwargs): class SphereFaceLayer(tf.keras.layers.Layer): class SphereFaceLayer(tf.keras.layers.Layer): """ r""" Implements the SphereFace loss from equation (7) of SphereFace: Deep Hypersphere Embedding for Face Recognition _ Implements the SphereFace loss from equation (7) of SphereFace: Deep Hypersphere Embedding for Face Recognition _ If the parameter original is set to True it will computes exactly what's written in eq (7): :math:\\text{soft}(x_i) = \\frac{exp(||x_i||\\text{cos}(\\psi(\\theta_{yi})))}{exp(||x_i||\\text{cos}(\\psi(\\theta_{yi}))) + \sum_{j;j\\neq yi} exp(||x_i||\\text{cos}(\psi(\\theta_{j}))) }. If the parameter original is set to True it will computes exactly what's written in eq (7): :math:\\text{soft}(x_i) = \\frac{exp(||x_i||\\text{cos}(\\psi(\\theta_{yi})))}{exp(||x_i||\\text{cos}(\\psi(\\theta_{yi}))) + \sum_{j;j\\neq yi} exp(||x_i||\\text{cos}(\psi(\\theta_{j}))) }. ... @@ -256,15 +260,6 @@ class ModifiedSoftMaxLayer(tf.keras.layers.Layer): ... @@ -256,15 +260,6 @@ class ModifiedSoftMaxLayer(tf.keras.layers.Layer): return logits return logits from tensorflow.keras.layers import ( BatchNormalization, Dropout, Dense, Concatenate, GlobalAvgPool2D, ) def add_bottleneck(model, bottleneck_size=128, dropout_rate=0.2): def add_bottleneck(model, bottleneck_size=128, dropout_rate=0.2): """ """ Amend a bottleneck layer to a Keras Model Amend a bottleneck layer to a Keras Model ... ...
 from .alexnet import AlexNet_simplified from .alexnet import AlexNet_simplified from .arcface import ArcFaceLayer from .arcface import ArcFaceLayer3Penalties from .arcface import ArcFaceModel from .densenet import DeepPixBiS from .densenet import DeepPixBiS from .densenet import DenseNet from .densenet import DenseNet from .densenet import densenet161 # noqa: F401 from .densenet import densenet161 # noqa: F401 from .mine import MineModel from .embedding_validation import EmbeddingValidation from .embedding_validation import EmbeddingValidation from .arcface import ArcFaceLayer, ArcFaceLayer3Penalties, ArcFaceModel from .mine import MineModel # gets sphinx autodoc done right - don't remove it # gets sphinx autodoc done right - don't remove it def __appropriate__(*args): def __appropriate__(*args): ... ...
 import math import tensorflow as tf import tensorflow as tf from .embedding_validation import EmbeddingValidation from bob.learn.tensorflow.metrics.embedding_accuracy import accuracy_from_embeddings from bob.learn.tensorflow.metrics.embedding_accuracy import accuracy_from_embeddings import math from .embedding_validation import EmbeddingValidation class ArcFaceModel(EmbeddingValidation): class ArcFaceModel(EmbeddingValidation): ... @@ -148,4 +151,3 @@ class ArcFaceLayer3Penalties(tf.keras.layers.Layer): ... @@ -148,4 +151,3 @@ class ArcFaceLayer3Penalties(tf.keras.layers.Layer): logits = self.s * logits logits = self.s * logits return logits return logits
 import tensorflow as tf import tensorflow as tf from bob.learn.tensorflow.metrics.embedding_accuracy import accuracy_from_embeddings from bob.learn.tensorflow.metrics.embedding_accuracy import accuracy_from_embeddings ... @@ -10,7 +11,8 @@ class EmbeddingValidation(tf.keras.Model): ... @@ -10,7 +11,8 @@ class EmbeddingValidation(tf.keras.Model): """ """ def compile( def compile( self, **kwargs, self, **kwargs, ): ): """ """ Compile Compile ... @@ -29,7 +31,6 @@ class EmbeddingValidation(tf.keras.Model): ... @@ -29,7 +31,6 @@ class EmbeddingValidation(tf.keras.Model): logits, _ = self(X, training=True) logits, _ = self(X, training=True) loss = self.loss(y, logits) loss = self.loss(y, logits) trainable_vars = self.trainable_variables self.optimizer.minimize(loss, self.trainable_variables, tape=tape) self.optimizer.minimize(loss, self.trainable_variables, tape=tape) self.compiled_metrics.update_state(y, logits, sample_weight=None) self.compiled_metrics.update_state(y, logits, sample_weight=None) ... ...
 from bob.learn.tensorflow.models import ( EmbeddingValidation, ArcFaceLayer, ArcFaceModel, ArcFaceLayer3Penalties, ) from bob.learn.tensorflow.layers import ( SphereFaceLayer, ModifiedSoftMaxLayer, ) import numpy as np import numpy as np from bob.learn.tensorflow.layers import ModifiedSoftMaxLayer from bob.learn.tensorflow.layers import SphereFaceLayer from bob.learn.tensorflow.models import ArcFaceLayer from bob.learn.tensorflow.models import ArcFaceLayer3Penalties def test_arcface_layer(): def test_arcface_layer(): ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!