Postprocess output of model.predict()

Hi!

I have an autoencoder that I have trained to encode and decode an image. After training I’m only using the encoder part of the autoencoder. The encoder outputs a feature vector. On inference (of the encoder) I need to compare the computed feature vector for some image with the mean feature vector computed from all training images. How can I adapt my model to do this step directly, so that the output of model.predict() returns the compared version of the feature vector and mean feature vector

I was looking into the possibility of overwriting the functionality of the model.predict() function. However, I don’t know if this is recommended.

What I’m doing now:

mean_feature_vector = (A np.array that consists of the mean feature vector for all n training images for the autoencoder)
feature_vector = model.predict(image)
# Compare feature vectors
comparison = np.linalg.norm(feature_vector-mean_feature_vector ) # The part that I want model.predict() to return

Hopefully my question makes sense, if not let me know :smiley:

Hi @Malthe

Welcome to the TensorFlow Forum!

Could you please tell us if this issue still persists? if so, Please share more details on the issue along with the minimal reproducible code to replicate and understand the issue. Thank you.