Thank you, I think I’m understading what you are saying. In this case, I have a CNN already trained with MNIST.
Now, if I pass an image as input to the trained model, the model will give me the activations of the classes (MNIST = 10 activations). But what I really want now is, with this information (which I already converted from tensor to numpy array):
out = out.view(out.size(0), -1)

For example, apply ridge regression (1.1. Linear Models — scikit-learn 0.24.0 documentation) to the array with this features extracted from the image, with shape = (1,1568). I just have to do this?
from sklearn import linear_model

reg = linear_model.RidgeCV(alphas=np.logspace(-6, 6, 13))

reg.fit(arr)

arr is the numpy array extracted from the layer previous to the last.
I don’t know if I made myself clear, but if you want I can provide more code in order to you understand better what I’m trying to say  .