擅长:python、mysql、java
<p>你可以编写一个自定义的激活函数,如下所示(例如加权Tanh)。在</p>
<pre><code>class weightedTanh(nn.Module):
def __init__(self, weights = 1):
super().__init__()
self.weights = weights
def forward(self, input):
ex = torch.exp(2*self.weights*input)
return (ex-1)/(ex+1)
</code></pre>
<p>{cd1>不要使用兼容的反向操作。在</p>