Combine scikit learn with pytorch

Hello, i am new to pytorch and i wanted to know can we combine pytorch dl models with other ml models from scikit learn?

First of all, welcome to the community!

You can use the deep learning models as a feature extractor. You need to create a pipeline like this:

  • First you input your data in the DL model to extract the features;
  • Then you input the extracted features in the sklearn model.

You need to train the models separately.

First of all thank you.
So basically i have to use two shared loss, one for training the DL model and one for the other model, and from DL have to use the last layer output before the prediction if i got it right

Yes. You need to train the DL model, then use the output of this model to train the sklearn model.

1 Like

Thank you very much for your purpose