Taking median of multiple models

I’ve independently trained multiple models on different datasets.

Out of these models, I’d like to construct another model where its weights are the element-wise median of my previously trained models.

What’s the best way of doing this?

Whether doing will yield any better model, i am not sure.

You can get median of weight tensors, e.g. like this.