test_arcface.py 975 Bytes
Newer Older
1
2
import numpy as np

3
4
5
6
7
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

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

def test_arcface_layer():

    layer = ArcFaceLayer()
    np.random.seed(10)
    X = np.random.rand(10, 50)
    y = [np.random.randint(10) for i in range(10)]

    assert layer(X, y).shape == (10, 10)


def test_arcface_layer_3p():

    layer = ArcFaceLayer3Penalties()
    np.random.seed(10)
    X = np.random.rand(10, 50)
    y = [np.random.randint(10) for i in range(10)]

    assert layer(X, y).shape == (10, 10)


def test_sphereface():

    layer = SphereFaceLayer()
    np.random.seed(10)
    X = np.random.rand(10, 10)

    assert layer(X).shape == (10, 10)


def test_modsoftmax():

    layer = ModifiedSoftMaxLayer()
    np.random.seed(10)
    X = np.random.rand(10, 10)

    assert layer(X).shape == (10, 10)