PyTorch Model Ensembler for Convolutional Neural Networks (CNN's)

username: QuantScientist
cooked: <p>Dear All,<br>
Dear All, As a service to the community, I decided to provide all my PyTorch ensembling code on github.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/7/7956ba5624a3c5e0c32ee843bb73328d2166134d.png" data-download-href="https://discuss.pytorch.org/uploads/default/7956ba5624a3c5e0c32ee843bb73328d2166134d" title="logo (1)"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/7/7956ba5624a3c5e0c32ee843bb73328d2166134d_2_690x347.png" alt="logo (1)" data-base62-sha1="hjpAqw7m6DE23cA0zMZxoBQezJH" width="690" height="347" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/7/7956ba5624a3c5e0c32ee843bb73328d2166134d_2_690x347.png, https://discuss.pytorch.org/uploads/default/original/2X/7/7956ba5624a3c5e0c32ee843bb73328d2166134d.png 1.5x, https://discuss.pytorch.org/uploads/default/original/2X/7/7956ba5624a3c5e0c32ee843bb73328d2166134d.png 2x" data-dominant-color="EEE2ED"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">logo (1)</span><span class="informations">793×399 23.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<a href="https://github.com/QuantScientist/Deep-Learning-Boot-Camp/tree/master/Kaggle-PyTorch" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/QuantScientist/Deep-Learning-Boot-Camp/tree/master/Kaggle-PyTorch</a></p>
<p>Introduction:<br>
Here, we investigate the effect of PyTorch model ensembles by combining the top-N single models crafted during the training phase. The results demonstrate that model ensembles may significantly outperform conventional single model approaches. Moreover, the method constructs an ensemble of deep CNN models with different architectures that are complementary to each other.</p>
<p>Ensemble learning:<br>
Ensemble learning is a technique of using several models or for solving a particular classification problem. Ensemble methods seek to promote diversity among the models they combine and reduce the problem related to overfitting of the training data-sets. The outputs of the individual models of the ensemble are combined (e.g. by averaging) to form the final prediction</p>
<p>During inference, the responses of the individual ConvNets of the ensemble are averaged to form the final classification. Both of these are well studied techniques in the machine learning community and relate to model averaging and over-fitting prevention.</p>
<p>If you want to investigate image classification by ensembling models, this is a repository that will help you out in doing so. It shows how to perform CNN ensembling in PyTorch with publicly available data sets. It is based on many hours of debugging and a bunch of of official pytorch tutorials/examples.</p>
<p>I felt that it was not exactly super trivial to perform ensembling in PyTorch, and so I thought I’d release my code as a tutorial which I wrote originally for my Kaggle. Using my code coupled with smart Ensembling, you can reach the top ~50 on the current board.</p>
<p>Do note that there may be bugs and errors, but it should run out of the box given it is pointed to the correct location of the data set on your local machine: parser.add_argument(‘–data_path’, default=‘d:/db/data/ice/’, type=str, help=‘Path to dataset’)</p>
<p>In addition, many parts of the code are just copies of other open source projects such as SeNet, DenseNet etc, all credit belongs to the original authors.</p>
<p>Feel free to clone/use/comment etc and I am always here to answer questions (on my free time …)</p>
<p>Best,</p>

username: John1231983
cooked: <p>Very good. Do you ensemble during training or just inference? How the gradient update if using ensemble during training</p>

username: Mohammed_Awney
cooked: <aside class="quote no-group" data-username="John1231983" data-post="2" data-topic="10952">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/john1231983/48/4040_2.png" class="avatar"> John1231983:</div>
<blockquote>
<p>How the gradient u</p>
</blockquote>
</aside>
<p>I want to know the answer</p>