Skip to content

Commit

Permalink
Calculate range [0, 1] in callbacks manually instead of using a MinMa…
Browse files Browse the repository at this point in the history
…xScaler from sklearn
  • Loading branch information
Szubie committed Sep 28, 2024
1 parent 0c2afe7 commit acda8d3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ivis/nn/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import numpy as np
import tensorflow as tf
from tensorflow.keras.callbacks import Callback
from sklearn.preprocessing import MinMaxScaler

# Matplotlib and seaborn are optional dependencies
try:
Expand Down Expand Up @@ -193,7 +192,7 @@ def on_epoch_end(self, epoch, logs=None):
self.plot_embeddings(filename)

def plot_embeddings(self, filename):
embeddings = MinMaxScaler((0, 1)).fit_transform(self.embeddings)
embeddings = (self.embeddings - self.embeddings.min()) / (self.embeddings.max() - self.embeddings.min())

fig = plt.figure()
sns.scatterplot(x=embeddings[:, 0], y=embeddings[:, 1], s=1,
Expand Down Expand Up @@ -269,7 +268,7 @@ def on_epoch_end(self, epoch, logs=None):
tf.summary.image("Embeddings", image, step=epoch)

def plot_embeddings(self, embeddings):
embeddings = MinMaxScaler((0, 1)).fit_transform(self.embeddings)
embeddings = (self.embeddings - self.embeddings.min()) / (self.embeddings.max() - self.embeddings.min())

fig = plt.figure()
buf = io.BytesIO()
Expand Down

0 comments on commit acda8d3

Please sign in to comment.