diff --git a/examples/notmnist.hs b/examples/notmnist.hs index 22701db..2628f16 100644 --- a/examples/notmnist.hs +++ b/examples/notmnist.hs @@ -43,7 +43,7 @@ module Main where let session = def { learningRate = 0.5 , batchSize = 32 - , epochs = 9 + , epochs = 10 , network = rnetwork , training = zip trinputs trlabels , test = zip teinputs telabels diff --git a/notmnist.png b/notmnist.png index 24d24b7..ff73904 100644 Binary files a/notmnist.png and b/notmnist.png differ diff --git a/sgd.png b/sgd.png index 0cba4b5..1f69105 100644 Binary files a/sgd.png and b/sgd.png differ diff --git a/src/Sibe.hs b/src/Sibe.hs index 371b9ae..3f18a7f 100644 --- a/src/Sibe.hs +++ b/src/Sibe.hs @@ -84,6 +84,7 @@ module Sibe , batchSize :: Int , chart :: [(Int, Double, Double)] , momentum :: Double + , biases :: Bool } deriving (Show) emptyNetwork = randomNetwork 0 (0, 0) 0 [] (0, (id, id)) @@ -97,6 +98,7 @@ module Sibe , batchSize = 0 , chart = [] , momentum = 0 + , biases = True } saveNetwork :: Network -> String -> IO () @@ -122,6 +124,9 @@ module Sibe runLayer :: Input -> Layer -> Output runLayer input (Layer !biases !weights _) = input <# weights + biases + runLayer' :: Input -> Layer -> Output + runLayer' input (Layer !biases !weights _) = input <# weights + forward :: Input -> Session -> Output forward input session = compute input (network session) where diff --git a/src/Sibe/Word2Vec.hs b/src/Sibe/Word2Vec.hs index d43876a..f1576d1 100644 --- a/src/Sibe/Word2Vec.hs +++ b/src/Sibe/Word2Vec.hs @@ -26,14 +26,16 @@ module Sibe.Word2Vec return trainingData let s = session { training = trainingData , network = buildNetwork 0 (-1, 1) v [(v, 25, (id, one))] (20, v, (softmax, crossEntropy')) + , biases = False } print trainingData - newses <- run (gd . learningRateDecay (1.1, 0.1) . ignoreBiases) s + newses <- run (gd . learningRateDecay (1.1, 0.1)) s let (hidden@(Layer biases nodes _) :- _) = network newses {-let computedVocVec = map (\(w, v) -> (w, forward v newses)) vocvec-} - let computedVocVec = map (\(w, v) -> (w, (fromRows [v]) <> nodes)) vocvec - print computedVocVec + print biases + let computedVocVec = map (\(w, v) -> (w, v <# nodes)) vocvec + {-print computedVocVec-} {-mapM_ (\(w, v) -> do putStr $ w ++ ": "