Can't Load My PyTorch Model

username: hustine316
cooked: <p>Hello good people. I recently trained a PyTorch model on a GPU enabled remote server and I saved it with the state_dict. I downloaded it and now wish to run it on my local machine on CPU. I tried to load it but I don’t know why it shows me an implementation error. Am I doing it wrong and is there any way around it? Kindly find below my model architecture (a slightly fine-tuned resnet18 model)<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/e/ce16655eabd02afaa9b60c384f3c0a1aa72b0e5e.png" data-download-href="https://discuss.pytorch.org/uploads/default/ce16655eabd02afaa9b60c384f3c0a1aa72b0e5e" title="im1"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/e/ce16655eabd02afaa9b60c384f3c0a1aa72b0e5e_2_690x388.png" alt="im1" data-base62-sha1="tp8lcUIlmg27NiUEQ6VUCqSrxNQ" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/e/ce16655eabd02afaa9b60c384f3c0a1aa72b0e5e_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/3X/c/e/ce16655eabd02afaa9b60c384f3c0a1aa72b0e5e_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/c/e/ce16655eabd02afaa9b60c384f3c0a1aa72b0e5e.png 2x" data-dominant-color="F2F3F4"><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">im1</span><span class="informations">1115×627 64.9 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>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/4/946da5e01e571a5ce65c24067eaf1304ff15d1a5.png" data-download-href="https://discuss.pytorch.org/uploads/default/946da5e01e571a5ce65c24067eaf1304ff15d1a5" title="im2"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/9/4/946da5e01e571a5ce65c24067eaf1304ff15d1a5_2_653x500.png" alt="im2" data-base62-sha1="lb3AhO9Pb6vpMzp5cTfQ1TOQoux" width="653" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/9/4/946da5e01e571a5ce65c24067eaf1304ff15d1a5_2_653x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/9/4/946da5e01e571a5ce65c24067eaf1304ff15d1a5_2_979x750.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/9/4/946da5e01e571a5ce65c24067eaf1304ff15d1a5.png 2x" data-dominant-color="F0F0F0"><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">im2</span><span class="informations">1070×819 116 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>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/a/1a5184001e5dabd6c7e4776c6186e68c9954a61e.png" data-download-href="https://discuss.pytorch.org/uploads/default/1a5184001e5dabd6c7e4776c6186e68c9954a61e" title="im3"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/a/1a5184001e5dabd6c7e4776c6186e68c9954a61e_2_690x394.png" alt="im3" data-base62-sha1="3KP3Lab78YG1nWU341pEzFfaEhw" width="690" height="394" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/a/1a5184001e5dabd6c7e4776c6186e68c9954a61e_2_690x394.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/a/1a5184001e5dabd6c7e4776c6186e68c9954a61e_2_1035x591.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/1/a/1a5184001e5dabd6c7e4776c6186e68c9954a61e.png 2x" data-dominant-color="F4F6F6"><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">im3</span><span class="informations">1120×641 87.6 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></p>
<p>Thank and hope to get a reply.</p>

username: hustine316
cooked: <p>I was able to get this by removing the “=”. It should be model.load_state_dict(…) instead of model = model.load_state_dict(…)</p>

username: InnovArul
cooked: <p>You have named a class called <code>model</code> and also have a variable with the same name (<code>model</code>).<br>
Try to keep different names to avoid confusion.</p>