packages feed

hmatrix-morpheus 0.1.0.1 → 0.1.0.2

raw patch · 2 files changed

+71/−5 lines, 2 filesdep ~hmatrix

Dependency ranges changed: hmatrix

Files

hmatrix-morpheus.cabal view
@@ -1,10 +1,12 @@ name:                hmatrix-morpheus-version:             0.1.0.1+version:             0.1.0.2 synopsis:            Low-level machine learning auxiliary functions. description:   Purely functional interface to morpheus based on hmatrix.   Morpheus library contains a bunch of cache line aware numerical algorithms   suitable for using as a low-level primitives to build machine learning applications.+  .+  Examples are in "Numeric.Morpheus" module. homepage:            https://github.com/Alexander-Ignatyev/morpheus/tree/master/hmatrix-morpheus license:             BSD3 license-file:        LICENSE@@ -33,7 +35,7 @@                      , Numeric.Morpheus.Activation                      , Numeric.Morpheus.MatrixReduce   build-depends:       base >= 4.7 && < 5-                     , hmatrix+                     , hmatrix >= 0.17.0.1   default-language:    Haskell2010   default-extensions:  ForeignFunctionInterface   include-dirs:        src@@ -76,7 +78,7 @@                      , Numeric.Morpheus.MatrixReduceTest   build-depends:       base                      , hmatrix-morpheus-                     , hmatrix+                     , hmatrix >= 0.17.0.1                      , MonadRandom >= 0.4.2.3                      , test-framework >= 0.8.1.1                      , test-framework-hunit >= 0.3.0.2@@ -92,7 +94,7 @@   other-modules:       Naive   build-depends:       base                      , hmatrix-morpheus-                     , hmatrix+                     , hmatrix >= 0.17.0.1                      , criterion   ghc-options:         -threaded -rtsopts -with-rtsopts=-N   default-language:    Haskell2010@@ -105,7 +107,7 @@   main-is:             Main.hs   build-depends:       base                      , hmatrix-morpheus-                     , hmatrix+                     , hmatrix >= 0.17.0.1   ghc-options:         -threaded -rtsopts -with-rtsopts=-N   default-language:    Haskell2010 
hmatrix-morpheus/src/Numeric/Morpheus.hs view
@@ -5,6 +5,70 @@ License: BSD-3 Stability: experimental Portability: POSIX+++Purely functional interface to morpheus based on hmatrix. Morpheus library contains a bunch of cache line aware numerical algorithms suitable for using as a low-level primitives to build machine learning applications.++Naive implementations, which do not take into account cache lines, would suffer order of magnitude performance degradation if tried to traverse a row major matrix in column order.++The library functions take into account CPU cache and work well for both row major and column major matrices, as you can see from the benchmark below which measure time for finding indices of max elements for every column and every row in comparison with naive approach:++@+| Benchmark                           | Morheus   | Naive    |++-------------------------------------+-----------+----------++| max index in columns - row major    | 0.9077 ms | 12.93 ms |++-------------------------------------+-----------+----------++| max index in columns - column major | 0.8778 ms | 1.490 ms |++-------------------------------------+-----------+----------++| max index in rows - row major       | 0.8622 ms | 1.504 ms |++-------------------------------------+-----------+----------++| max index in rows - column major    | 0.8913 ms | 12.80 ms |++-------------------------------------+-----------+----------++@++== Examples++@+import Numeric.LinearAlgebra+import Numeric.Morpheus+++a = matrix 5 [+  71, 11, 3,  -9, -7,+  21, -7,  -2,  23, 11,+  -11, 32, 53, -49, 37,+  1,  -24, 78, 90, 17+  ]+++main :: IO ()+main = do+  putStrLn "Numeric.Morpheus.MatrixReduce functions: "++  putStr "sum of elements of rows: "+  print $ rowSum a++  putStr "product of elements of rows: "+  print $ rowPredicate (*) a++  putStr "max values of columns: "+  print $ fst $ columnMaxIndex a++  putStr "indices of max values of columns: "+  print $ snd $ columnMaxIndex a+++  putStrLn "Numeric.Morpheus.Activation functions: "++  putStrLn "\nSigmoid:"+  disp 3 (sigmoid a)++  putStrLn "ReLu:"+  disp 3 (relu a)++  putStrLn "ReLu gradient:"+  disp 3 (reluGradient a)+@ -}  module Numeric.Morpheus