Commit 3bd7d6ba authored by lucas_miranda's avatar lucas_miranda
Browse files

Modified cluster purity computation. Instead of KNN, we now look at...

Modified cluster purity computation. Instead of KNN, we now look at neighborhoods of a predefined radius
parent 106e8146
......@@ -216,7 +216,7 @@ class neighbor_cluster_purity(tf.keras.callbacks.Callback):
super().__init__()
self.variational = variational
self.validation_data = validation_data
self.r = r
self.r = r # Make radius default depend on encoding dimensions
self.samples = samples
self.log_dir = log_dir
......
......@@ -13,6 +13,7 @@ from hypothesis import HealthCheck
from hypothesis import settings
from hypothesis import strategies as st
from hypothesis.extra.numpy import arrays
import deepof.models
import deepof.model_utils
import numpy as np
import tensorflow as tf
......@@ -272,13 +273,13 @@ def test_neighbor_cluster_purity():
X = np.random.uniform(0, 10, [1500, 5])
y = np.random.randint(0, 2, [1500, 1])
test_model = tf.keras.Sequential()
test_model.add(tf.keras.layers.Dense(1))
test_model.compile(
loss=tf.keras.losses.binary_crossentropy,
optimizer=tf.keras.optimizers.SGD(),
)
test_model = deepof.models.SEQ_2_SEQ_GMVAE()
test_model.build(X.shape)
test_model.fit(X, y, callbacks=deepof.model_utils.neighbor_cluster_purity())
test_model.fit(
X,
y,
callbacks=deepof.model_utils.neighbor_cluster_purity(
validation_data=X, variational=True
),
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment