The traditional way is to train the full network (CNN + FC), and then
replace the FC with an SVM. The reason you need the FC layers is to
give the model a chance of optimising the CNN, because you need access
to the gradients. Once the network is fully trained, you will just
ignore the FC, extract the features, and train the SVM.
Original paper:
http://deeplearning.net/wp-content/uploads/2013/03/dlsvm.pdf
Example code:
model = load_model('saved_model.h5')
layer = model.layers[-9] # Adjust here to the right depth.
tensor = layer.get_output_at(0)
f = K.function(model.inputs + [K.learning_phase()], (tensor,))
X_train_svm = f(X_train)
I know there are differentiable implementations of SVM and random
forests that you can use instead of the FC, but I haven't seen them in
action, and I haven't read any paper reporting their performance. My
guess is that they have the ability to be a bit better than the FC,
but probably computationally much more intensive.
> --
> You received this message because you are subscribed to the Google Groups
> "Keras-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
keras-users...@googlegroups.com.
> To view this discussion on the web, visit
>
https://groups.google.com/d/msgid/keras-users/d501e31b-93f2-4447-8a90-d15bf711f4ac%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.