예제 #1
0
def test_batch_dataset_build():
    x = np.zeros((1, 784))
    y = np.zeros(1)

    new_batch_dataset = batch.BatchDataset(x, y, shuffle=True)

    assert new_batch_dataset.batches is not None

    new_batch_dataset = batch.BatchDataset(x, y, shuffle=False)

    assert new_batch_dataset.batches is not None
예제 #2
0
def test_batch_dataset_batches():
    x = np.zeros((1, 784))
    y = np.zeros(1)

    new_batch_dataset = batch.BatchDataset(x, y)

    assert new_batch_dataset.batches is not None
예제 #3
0
def test_triplet_evaluate():
    (x, y), (_, _) = tf.keras.datasets.mnist.load_data()
    train = batch.BatchDataset(x[:10], y[:10], input_shape=(10, 784))

    new_base = mlp.MLP()
    new_siamese = triplet.TripletSiamese(new_base)
    new_siamese.compile(optimizer=tf.optimizers.Adam(learning_rate=0.001))

    new_siamese.fit(train.batches, epochs=1)
    new_siamese.evaluate(train.batches)
예제 #4
0
def test_batch_dataset_batches_setter():
    x = np.zeros((1, 784))
    y = np.zeros(1)

    new_batch_dataset = batch.BatchDataset(x, y)

    try:
        new_batch_dataset.batches = 1
    except:
        pass

    assert new_batch_dataset.batches != 1
예제 #5
0
def test_triplet_predict():
    (x, y), (_, _) = tf.keras.datasets.mnist.load_data()
    train = batch.BatchDataset(x[:10], y[:10], input_shape=(10, 784))

    new_base = mlp.MLP()
    new_siamese = triplet.TripletSiamese(new_base)
    new_siamese.compile(optimizer=tf.optimizers.Adam(learning_rate=0.001))

    new_siamese.fit(train.batches, epochs=1)

    x1 = tf.ones((1, 784))
    x2 = tf.ones((1, 784))

    new_siamese.distance = "L1"
    new_siamese.predict(x1, x2)

    new_siamese.distance = "L2"
    new_siamese.predict(x1, x2)

    new_siamese.distance = "angular"
    new_siamese.predict(x1, x2)