history = model.fit(x_spectro_train, y_train_onehot, batch_size=batch_size, epochs=training_epochs, validation_data =(x_spectro_test, y_test_onehot), shuffle=True, callbacks=callbacks_list,class_weight=class_weights, verbose=1)
model=load_model(model_name)
predict_prob_train = model.predict(x_spectro_train,batch_size=batch_size)
inp = model.input # input placeholder
outputs = [layer.output for layer in model.layers] # all layer outputs
functors = [K.function([inp, K.learning_phase()], [out]) for out in outputs] # evaluation functions
layer_outs = [func([x_spectro_train, 0.]) for func in functors] #test mode (0.0), train mode(1.0)
I want to save CNN layer outputs. I want to train the svm model with CNN layer outputs (not probability)
So I used code from Keras, How to get the output of each layer? and I saw the result.
But my result of CNN layer is different from the result of model.predict. I monitored the val accuracy, save the best model, and load it. This is structure of my model. (below image)
I expected that result of layer_outs[13] (last layer) is same with predict_prob_train. However, the results were different. (like below image)
Why the results are different?