How to save features extracted by a layer of a CNN model, let say output of AVGPOOL layer of a pretrained Resnet modelt

i meed to use SVM classifier instead of Softmax, so for that i want to create a feature matrix of the training set to apply PCA on this and then train the SVM classifier.
i want to know how to save the extracted features by the avg pool layer of the pretrained Resenet model to create a feature set of all the images in the training set to apply PCA and then SVM.