Solved by ptrblck in post #2 
              
              
                Your code should work, if you replace the numpy as Keras calls with their PyTorch equivalent: 
def tempsigmoid(x):
    nd=3.0 
    temp=nd/torch.log(torch.tensor(9.0)) 
    return torch.sigmoid(x/(temp))