Solved by ptrblck in post #2 
              
              
                I’m not sure I understand the use case correctly, but in case you want to apply torch.cos and torch.sin on an activation you could directly do it via: 
def forward(self, x): # forward method of your model
    ...
    x = self.layer(x)
    ...
    x = torch.sin(x)
    x = torch.cos(x)
    ...
    ret…