Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated cabal file and Neuron module

  • Loading branch information...
commit fa836a200ac28cd6d6c6771d6685458628e02689 1 parent 1989c1e
@alpmestan authored
Showing with 12 additions and 45 deletions.
  1. +1 −0  .gitignore
  2. +5 −5 AI/HNN/Neuron.hs
  3. +6 −40 hnn.cabal
View
1  .gitignore
@@ -1,3 +1,4 @@
+cabal-dev/
dist/
*~
*.o
View
10 AI/HNN/Neuron.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE BangPatterns, RecordWildCards #-}
-module Net (Neuron(..), compute, sigmoid, tanh) where
+module AI.HNN.Neuron (Neuron(..), compute, sigmoid, sigmoid', tanh) where
-- tanh is from Prelude
import Data.Vector.Unboxed (Vector, Unbox)
@@ -8,7 +8,7 @@ import qualified Data.Vector.Unboxed as U
-- | Our Neuron type, parametrized by the "number" type, which should be:
--- 1/ an instance of Num
+-- 1/ an instance of Num (Floating wouldn't hurt for common activation funcs)
-- 2/ an instance of Data.Vector.Unboxed.Unbox
data Neuron a = Neuron
{ weights :: !(Vector a)
@@ -21,7 +21,7 @@ compute :: (Num a, Unbox a) => Neuron a -> Vector a -> a
compute (Neuron{..}) !inputs = activation $ U.sum (U.zipWith (*) weights inputs)
{-# SPECIALIZE compute :: Neuron Double -> Vector Double -> Double #-}
{-# SPECIALIZE compute :: Neuron Float -> Vector Float -> Float #-}
-{-# INLINE compute #-}
+-- not sure if it's best to specialize or just INLINE
sigmoid :: Floating a => a -> a
sigmoid !x = 1 / (1 + exp (-x))
@@ -32,8 +32,8 @@ sigmoid' !x = case sigmoid x of
{-# SPECIALIZE sigmoid :: Double -> Double #-}
{-# SPECIALIZE sigmoid :: Float -> Float #-}
-{-# INLINE sigmoid #-}
+-- same
{-# SPECIALIZE sigmoid' :: Double -> Double #-}
{-# SPECIALIZE sigmoid' :: Float -> Float #-}
-{-# INLINE sigmoid' #-}
+-- same
View
46 hnn.cabal
@@ -1,58 +1,24 @@
-- Initial hnn.cabal generated by cabal init. For further documentation,
-- see http://haskell.org/cabal/users-guide/
--- The name of the package.
name: hnn
-
--- The package version. See the Haskell package versioning policy (PVP)
--- for standards guiding when and how versions should be incremented.
--- http://www.haskell.org/haskellwiki/Package_versioning_policy
--- PVP summary: +-+------- breaking API changes
--- | | +----- non-breaking API additions
--- | | | +--- code changes with no API change
version: 0.2.0.0
-
-synopsis: A simple and fast neural networks library in haskell
-
--- A longer description of the package.
+synopsis: A fast and simple neural network library
-- description:
-
--- URL for the project homepage or repository.
homepage: http://github.com/alpmestan/hnn
-
--- The license under which the package is released.
license: BSD3
-
--- The file containing the license text.
license-file: LICENSE
-
--- The package author(s).
-author: Alp Mestanogullari <alpmestan@gmail.com>
-
--- An email address to which users can send suggestions, bug reports, and
--- patches.
+author: Alp Mestanogullari <alpmestan@gmail.com>, Gatlin Johnson <rokenrol@gmail.com>
maintainer: Alp Mestanogullari <alpmestan@gmail.com>
-
--- A copyright notice.
-- copyright:
-
-category: AI, Math
-
+category: AI
build-type: Simple
-
--- Constraint on the version of Cabal needed to build this package.
cabal-version: >=1.8
-
library
- -- Modules exported by the library.
- -- exposed-modules:
-
- -- Modules included in this library but not exported.
+ exposed-modules: AI.HNN.Neuron
-- other-modules:
-
- -- Other library packages from which modules are imported.
build-depends: base ==4.5.*,
vector,
- ad
-
+ mwc-random
+ ghc-options: -O2 -funbox-strict-fields
Please sign in to comment.
Something went wrong with that request. Please try again.