Advertisement
nezvers

NN Activation functions in GDscript

Sep 23rd, 2020
1,179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1.  
  2. # Hyperbolic Tanjant Function
  3. func _tanh(x, derivative=false)->float:
  4.     if derivative:
  5.         return(1 - pow(x, 2))
  6.     return tanh(x)
  7.  
  8. # ReLU Function
  9. func re(x:float)->float:
  10.     return x * int(x>0)
  11.  
  12. # Leaky ReLU Function
  13. func lr(x:float)->float:
  14.     if x < 0:
  15.         return (x/10.0)
  16.     else:
  17.         return x
  18.  
  19. # Sigmoid Function
  20. func sigmoid(x:float)->float:
  21.     return (1/(1+exp(-x)))
  22.  
  23. func swish(x:float)->float:
  24.     return sigmoid(x)*x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement