Hello, I’m trying to store a neural network to redisAI in docker.
The neuralnet is :
class AnomalyDetector(Model):
def __init__(self):
super(AnomalyDetector, self).__init__()
self.encoder = tf.keras.Sequential([
layers.Dense(6, activation="relu"),
layers.Dense(3, activation="relu"),
layers.Dense(1, activation="relu")])
self.decoder = tf.keras.Sequential([
layers.Dense(3, activation="relu"),
layers.Dense(6, activation="sigmoid")])
def call(self, x):
encoded = self.encoder(x)
decoded = self.decoder(encoded)
return decoded
ae = AnomalyDetector()
ae.compile(optimizer='adam', loss='mse')
history = ae.fit(data, data, epochs=15, batch_size=256, shuffle=True)
reconstructions = ae.predict(data)
perte = tf.keras.losses.mse(reconstructions, data)
print("Perte min :", np.min(perte))
print("Perte max :", np.max(perte))
print("Perte moyenne :", np.mean(perte))
seuil = np.percentile(perte, 99.5)
print("Seuil :", seuil)
print("*** Sauvegarde du modèle et du seuil ***")
time.sleep(2)
ae.save(_ae_ip)
The command to store the model is :
cat data/autoencoder/ip/ | docker exec -i redisai redis-cli -x AI.MODELSTORE mymodel TF CPU INPUTS 2 a b OUTPUTS 1 c BLOB