Created
December 23, 2014 15:25
-
-
Save delta2323/1b40807de3a6515b7b78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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