Possibility of combining two model with different classes on Pytorch

Hi guys, just wondering if it is possible to combine two different model training on different dataset into one?
To illustrate my goal

For model A: I have A.pth
For model B(red colour): I have B.pth

Is it possible to combine them into one since the data is too skewed

Hi Ahn!

You won’t be able to combine the two models together in some naive
way. The problem is that while model A has learned to distinguish a
“Worm” from a “Brittlestar” and model B has learned to distinguish a
“Prawn” from a “Seaspider,” neither model has learned to distinguish
a “Worm” from a “Prawn.”

So unless you do some training where your training data includes
both “Worm” and “Prawn” samples, your combined model will likely
not work well.

You appear to be training a multi-class classifier. A standard loss
function for doing so is CrossEntropyLoss. One common technique for
dealing with skewed (unbalanced) data is to use CrossEntropyLoss’s
weight constructor-argument to weight less common classes more
heavily in your training.

Depending on how your training data is structured, you could also
experiment with WeightedRandomSampler.

Good luck.

K. Frank