<p dir="auto">Hi,</p>
<p dir="auto">I find that optimizer enforces every parameter to be <code class="notranslate">requires_grad=True</code>. However, if I used such a network where the first layer was a pre-trained <code class="notranslate">AlexNet</code> with every parameter set to <code class="notranslate">requires_grad = False</code>, and rest layers were left <code class="notranslate">requires_grad = True</code>, pytorch would complain <code class="notranslate">optimizing a parameter that doesn't require gradients</code>. Because in <code class="notranslate">model.parameters()</code>, some parameters do not require gradients.</p>
<p dir="auto">Is there anything wrong with my method of freezing part of the model? or would it be better to enforce that not all parameters are set <code class="notranslate">requires_grad=False</code> .</p>
<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<p dir="auto">Many projects use QT for UI, but when compiling such code a special keyword "slots" is defined, which conflicts with the 'slots' function defined in IValue. Since IValue.h ends up being included when including Torch headers, this prevents using Torch in any code that also does QT stuff.</p>
<p dir="auto">Even though this is not the fault of Torch, since QT is a popular cross-platform GUI library, it would probably be great for usability if that function is somehow renamed or some other smart trick is used.</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<p dir="auto">Tested with current Torch master.</p>
<ol dir="auto">
<li>Include some Torch headers in a file that uses QT slots functionality.</li>
</ol>