AttributeError: module 'torch.nn' has no attribute 'SiLU'

I m using the pytorch version “1.5.0” . By usin Silu its saying that " AttributeError: module ‘torch.nn’ has no attribute ‘SiLU’ " How can i use SiLU activation function.

AttributeError                            Traceback (most recent call last)
<ipython-input-105-d64bc46f9e10> in <module>
      1 # instantiate  the class LSTM1 object
----> 2 lstm1 = LSTM1(num_classes, input_size, hidden_size, num_layers, 1) #our lstm class

<ipython-input-99-6ae20c79c8d0> in __init__(self, num_classes, input_size, hidden_size, num_layers, seq_length)
     13         self.fc = nn.Linear(50, num_classes) #fully connected last layer
     14 
---> 15         self.relu = nn.SiLU()
     16 
     17     def forward(self,x):

AttributeError: module 'torch.nn' has no attribute 'SiLU'

You would need to upgrade your PyTorch or backport the SiLU implementation.

1 Like