draw chart using simple options

This commit is contained in:
Mahdi Dibaiee 2016-09-16 14:16:14 +04:30
parent 0d43814448
commit 6def5f6197
4 changed files with 20 additions and 1024 deletions

View File

@ -47,20 +47,14 @@ module Main where
, network = rnetwork , network = rnetwork
, training = zip trinputs trlabels , training = zip trinputs trlabels
, test = zip teinputs telabels , test = zip teinputs telabels
, drawChart = True
, chartName = "notmnist.png"
} :: Session } :: Session
let initialCost = crossEntropy session let initialCost = crossEntropy session
newsession <- run (sgd . learningRateDecay (1.1, 5e-2)) session newsession <- run (sgd . learningRateDecay (1.1, 5e-2)) session
let el = map (\(e, l, _) -> (e, l)) (chart newsession)
ea = map (\(e, _, a) -> (e, a)) (chart newsession)
toFile Chart.def "notmnist.png" $ do
Chart.layoutlr_title Chart..= "loss over time"
Chart.plotLeft (Chart.line "loss" [el])
Chart.plotRight (Chart.line "learningRate" [ea])
let cost = crossEntropy newsession let cost = crossEntropy newsession
putStrLn "parameters: " putStrLn "parameters: "

1012
log

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -85,6 +85,8 @@ module Sibe
, epoch :: Int , epoch :: Int
, batchSize :: Int , batchSize :: Int
, chart :: [(Int, Double, Double)] , chart :: [(Int, Double, Double)]
, drawChart :: Bool
, chartName :: String
, momentum :: Double , momentum :: Double
, debug :: Bool , debug :: Bool
} deriving (Show) } deriving (Show)
@ -99,6 +101,8 @@ module Sibe
, epoch = 0 , epoch = 0
, batchSize = 0 , batchSize = 0
, chart = [] , chart = []
, drawChart = False
, chartName = "chart.png"
, momentum = 0 , momentum = 0
, debug = False , debug = False
} }
@ -253,6 +257,15 @@ module Sibe
let newnet = foldl' (\n (input, label) -> train input n label alpha) net pairs let newnet = foldl' (\n (input, label) -> train input n label alpha) net pairs
let el = map (\(e, l, _) -> (e, l)) (chart session)
ea = map (\(e, _, a) -> (e, a)) (chart session)
when (drawChart session) $ do
toFile Chart.def (chartName session) $ do
Chart.layoutlr_title Chart..= "loss over time"
Chart.plotLeft (Chart.line "loss" [el])
Chart.plotRight (Chart.line "learningRate" [ea])
return session { network = newnet return session { network = newnet
, epoch = epoch session + 1 , epoch = epoch session + 1
} }
@ -285,7 +298,8 @@ module Sibe
let el = map (\(e, l, _) -> (e, l)) (chart session) let el = map (\(e, l, _) -> (e, l)) (chart session)
ea = map (\(e, _, a) -> (e, a)) (chart session) ea = map (\(e, _, a) -> (e, a)) (chart session)
toFile Chart.def "sgd.png" $ do when (drawChart session) $ do
toFile Chart.def (chartName session) $ do
Chart.layoutlr_title Chart..= "loss over time" Chart.layoutlr_title Chart..= "loss over time"
Chart.plotLeft (Chart.line "loss" [el]) Chart.plotLeft (Chart.line "loss" [el])
Chart.plotRight (Chart.line "learningRate" [ea]) Chart.plotRight (Chart.line "learningRate" [ea])