0 | module NN.Architectures.Activations
 1 |
 2 | import Data.Tensor
 3 | import Data.Para
 4 | import Misc
 5 |
 6 | -- Should this be a typeclass?
 7 | public export
 8 | relu : Ord a => Num a => a -> a
 9 | relu x = max 0 x
10 |
11 | public export
12 | sigmoid : Fractional a => Exp a => a -> a
13 | sigmoid x = ex / (1 + ex) where ex = exp x
14 |
15 |
16 | namespace Tensor
17 |   public export
18 |   relu : Ord a => Num a => {shape : TensorShape rank} ->
19 |     Tensor shape a -> Tensor shape a
20 |   relu t = relu <$> t
21 |  
22 |   public export
23 |   sigmoid : Fractional a => Exp a =>
24 |     {0 shape : TensorShape rank} ->
25 |     Tensor shape a -> Tensor shape a
26 |   sigmoid t = sigmoid <$> t
27 |