Skip to content

Instantly share code, notes, and snippets.

@delta2323
Created December 23, 2014 15:25
Show Gist options
  • Save delta2323/1b40807de3a6515b7b78 to your computer and use it in GitHub Desktop.
Save delta2323/1b40807de3a6515b7b78 to your computer and use it in GitHub Desktop.
-- NN.Network
module NN.Network where
type Blob = [Float]
data Network d1 d2 = Nw (d1 -> d2)
class INetwork n where
forward :: n d1 d2 -> d1 -> d2
(.) :: n d2 d3 -> n d1 d2 -> n d1 d3
instance INetwork Network where
forward (Nw f) x = f x
(Nw g) . (Nw f) = Nw (g Prelude.. f)
--Main
module Main where
import qualified NN.Network as N
n = N.Nw (fmap (+1))
m = N.Nw (fmap (*2))
l = m N.. n
main = putStrLn $ show $ N.forward l [2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment