Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- sampleCollect :: (PrimMonad m, MonadIO m, MonoFoldable t) => TBQueue (Element t) -> Maybe Int -> (Int -> m ()) -> t -> Gen (PrimState m) -> ConduitT i (Element t) m ()
- trainReport :: (MonadIO m, NFData a) => TBQueue i -> (Int -> m ()) -> Int -> (NominalDiffTime -> [i] -> a -> m ()) -> ConduitT a a m ()
- dispEpoch :: MonadIO m => Int -> m ()
- dispBatch :: MonadIO m => Int -> m ()
- simpleReport :: MonadIO m => Maybe [i] -> ([i] -> a -> String) -> NominalDiffTime -> [i] -> a -> m ()
- simpleRunner :: forall m t a b n. (MonadIO m, PrimMonad m, NFData a, MonoFoldable t) => SimpleOpts m (Element t) a b -> t -> SOOptimizer m n (Element t) a -> RunOpts m a -> a -> Opto n (Element t) a -> Gen (PrimState m) -> m b
- data SimpleOpts m i a b = SO {
- soEpochs :: Maybe Int
- soDispEpoch :: Int -> m ()
- soDispBatch :: Int -> m ()
- soTestSet :: Maybe [i]
- soSkipSamps :: Int
- soEvaluate :: [i] -> a -> String
- soSink :: ConduitT a Void m b
- data SOOptimizer :: (Type -> Type) -> (Type -> Type) -> Type -> Type -> Type where
- SOSingle :: SOOptimizer m (ConduitT i a m) i a
- SOParallel :: MonadUnliftIO m => ParallelOpts m a -> SOOptimizer m m i a
- SOParChunked :: MonadUnliftIO m => ParallelOpts m a -> SOOptimizer m (StateT [i] m) i a
Simple conduit runners
:: (PrimMonad m, MonadIO m, MonoFoldable t) | |
=> TBQueue (Element t) | Queue to deposit samples |
-> Maybe Int | Number of epochs (Nothing for forever) |
-> (Int -> m ()) | Report each new epoch. See |
-> t | Collection to source |
-> Gen (PrimState m) | Random shuffling generator |
-> ConduitT i (Element t) m () |
:: (MonadIO m, NFData a) | |
=> TBQueue i | Queue to acquire used training samples |
-> (Int -> m ()) | Report each new batch. See |
-> Int | Number of samples to go through before running reporting function |
-> (NominalDiffTime -> [i] -> a -> m ()) | Reporting function. See |
-> ConduitT a a m () |
A conduit that processes "trained" items and outputs a report every
report batch, based on samples accumulated in a TBQueue
. Meant to be used
alongside sampleCollect
. It passes through all of its input.
sampleCollect
sampleQueue epochsdispEpoch
samples .|optoConduit
ro model0 optimizer .|trainReport
sampleQueuedispBatch
2500 (simpleReport
(Just
valSet) runTest) .| sink -- (other stuff you would want to do with trained models)
Simple callbacks for runners
dispEpoch :: MonadIO m => Int -> m () Source #
Simple reporter to give to sampleCollect
:
[Epoch 1] [Epoch 2] [Epoch 3]
dispBatch :: MonadIO m => Int -> m () Source #
Simple reporter to give to trainReport
:
(Batch 1) (Batch 2) (Batch 3)
:: MonadIO m | |
=> Maybe [i] | A "validation set" that's consistent across all batches. |
-> ([i] -> a -> String) | A function to run to evaluate a set. |
-> NominalDiffTime | Time it took to train |
-> [i] | Set of batch points |
-> a | New predictor |
-> m () |
Simple reporting callback to provide trainReport
.
Integrated runners
:: (MonadIO m, PrimMonad m, NFData a, MonoFoldable t) | |
=> SimpleOpts m (Element t) a b | Options |
-> t | Collection of samples |
-> SOOptimizer m n (Element t) a | Choice of optimizer concurrency strategy |
-> RunOpts m a | Runner options |
-> a | Initial value |
-> Opto n (Element t) a | Optimizer |
-> Gen (PrimState m) | Random generator |
-> m b |
Integrate sampleCollect
and trainReport
together, automatically
generating the sample queue and supplying all callbacks based on the
SimpleOpts
.
data SimpleOpts m i a b Source #
Options for simpleRunner
. def
gives sensible defaults.
SO | |
|
Instances
(MonadIO m, Default b) => Default (SimpleOpts m i a b) Source # | |
Defined in Numeric.Opto.Run.Simple def :: SimpleOpts m i a b # |
data SOOptimizer :: (Type -> Type) -> (Type -> Type) -> Type -> Type -> Type where Source #
Choose a concurrency strategy for your runner.
SOSingle :: SOOptimizer m (ConduitT i a m) i a | Single-threaded |
SOParallel :: MonadUnliftIO m => ParallelOpts m a -> SOOptimizer m m i a | Parallel |
SOParChunked :: MonadUnliftIO m => ParallelOpts m a -> SOOptimizer m (StateT [i] m) i a | Parallel chunked |