擅长:python、mysql、java
<p>你可以在使用hardmax之前给输出加上噪声。特别是,可以使用<code>C.random.gumbel</code>或<code>C.random.gumbel_like</code>按比例采样{<cd3>}。这被称为<a href="https://hips.seas.harvard.edu/blog/2013/04/06/the-gumbel-max-trick-for-discrete-distributions/" rel="nofollow noreferrer">gumbel-max trick</a>。<a href="https://www.cntk.ai/pythondocs/cntk.random.html" rel="nofollow noreferrer">cntk.random</a>模块也包含其他分布,但是如果您有对数概率,您很可能希望在hardmax之前添加gumbel noise。一些代码:</p>
<pre><code>@C.Function
def randomized_hardmax(x):
noisy_x = x + C.random.gumbel_like(x)
return C.hardmax(noisy_x)
</code></pre>
<p>然后将您的<code>hardmax</code>替换为<code>randomized_hardmax</code>。在</p>