PReLU.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. --- /usr/local/lib/python3.5/dist-packages/torch/nn/modules/activation.py
  2. +++ /usr/local/lib/python3.5/dist-packages/torch/nn/modules/activation.py
  3. @@ -37,9 +37,10 @@
  4. - Output: :math:`(N, *)`, same shape as the input
  5. Attributes:
  6. - weight (Tensor): the learnable weights of shape (:attr:`num_parameters`).
  7. + weight (Tensor): the learnable weights of shape (attr:`num_parameters`).
  8. + The attr:`dtype` is default to
  9. - .. image:: ../scripts/activation_images/PReLU.png
  10. + .. image:: scripts/activation_images/PReLU.png
  11. Examples::
  12. @@ -47,17 +48,16 @@
  13. >>> input = torch.randn(2)
  14. >>> output = m(input)
  15. """
  16. - __constants__ = ['num_parameters']
  17. - num_parameters: int
  18. - def __init__(self, num_parameters: int = 1, init: float = 0.25) -> None:
  19. + def __init__(self, num_parameters=1, init=0.25):
  20. self.num_parameters = num_parameters
  21. super(PReLU, self).__init__()
  22. self.weight = Parameter(torch.Tensor(num_parameters).fill_(init))
  23. - def forward(self, input: Tensor) -> Tensor:
  24. + @weak_script_method
  25. + def forward(self, input):
  26. return F.prelu(input, self.weight)
  27. - def extra_repr(self) -> str:
  28. + def extra_repr(self):
  29. return 'num_parameters={}'.format(self.num_parameters)