I have a Keras model saved in a .h5
file. As you know there are a y_pred
and a y_act
that confusion matrix creates from, at run time, it's easy to get y_pred
values but my model is saved and now I need the y_pred
values from that saved model. Is there a way to do that?
1 Answer
If I've figured it out correctly, the answer is no. The point is that your saved model solely contains the network architecture and the parameters it has. What you want relates to the recall phase where you have to provide input to get output. This means that you need input data to be fed to your network in order to get output. What you want can be done using another approach. First, load your network and feed your data to your model. After that, get the outputs and store the inputs and outputs alongside each other using Numpy
save method or maybe .h5 format.
The flow for achieving the y_pred
can be like the following sequence of actions:
- Load your model.
- Feed your data to your model and get
y_pred
. - define a
Numpy
array of inputs and aNumpy
array of outputs. - Store inputs, real outputs and
y_preds
using the methods which are available. - Later, when you want to make your confusion matrix, you can load your inputs and outputs, and the real outputs to make your matrix.
-
$\begingroup$ could give more explanation about you approach? I don't think this way gives me y_pred values? the y_pred is only consists of 0 and 1. $\endgroup$– HunarCommented Jul 11, 2019 at 7:46