I have a prediction routine that involves doing some postprocessing of the output of model.predict(x) function. The postprocessing involves a comparison of the output to a the mean output of all training data. The process has worked well until now, but I would like to combine it all, mean training vector included, into a TF SavedModel. I.e. I’m trying to get the final output (postprocessing included) when calling model.predict(x)
Is there any way to customize the functionality of the model.predict(x) function?
What my current pipeline looks like:
mean_training_output = # an array consisting of the mean output vector from the training data predicted = model.predict(x) # Compare distance of new and mean training output normalized_distance = np.zeros(len(predicted)) for i in range(len(predicted)): normalized_distance[i] = np.linalg.norm(feature_vectors_flattned[i]-mean_training_output) # What I actually want model.predict() to output normalized_distance
So in the above snippet I would actually want model.predict() to output normalized_distance.