mirror of
https://github.com/tensorflow/haskell.git
synced 2024-12-26 19:49:46 +01:00
62 lines
2.1 KiB
Text
62 lines
2.1 KiB
Text
|
-- Hoogle documentation, generated by Haddock
|
||
|
-- See Hoogle, http://www.haskell.org/hoogle/
|
||
|
|
||
|
|
||
|
-- | TensorBoard related functionality.
|
||
|
--
|
||
|
-- Please see README.md
|
||
|
@package tensorflow-logging
|
||
|
@version 0.1.0.0
|
||
|
|
||
|
|
||
|
-- | TensorBoard Summary generation. Provides type safe wrappers around raw
|
||
|
-- string emitting CoreOps.
|
||
|
--
|
||
|
-- Example use:
|
||
|
--
|
||
|
-- <pre>
|
||
|
-- -- Call summary functions while constructing the graph.
|
||
|
-- createModel = do
|
||
|
-- loss <- -- ...
|
||
|
-- TF.scalarSummary loss
|
||
|
--
|
||
|
-- -- Write summaries to an EventWriter.
|
||
|
-- train = TF.withEventWriter "/path/to/logs" $ \eventWriter -> do
|
||
|
-- summaryTensor <- TF.build TF.allSummaries
|
||
|
-- forM_ [1..] $ \step -> do
|
||
|
-- if (step % 100 == 0)
|
||
|
-- then do
|
||
|
-- ((), summaryBytes) <- TF.run (trainStep, summaryTensor)
|
||
|
-- let summary = decodeMessageOrDie (TF.unScalar summaryBytes)
|
||
|
-- TF.logSummary eventWriter step summary
|
||
|
-- else TF.run_ trainStep
|
||
|
-- </pre>
|
||
|
module TensorFlow.Logging
|
||
|
|
||
|
-- | Handle for logging TensorBoard events safely from multiple threads.
|
||
|
data EventWriter
|
||
|
|
||
|
-- | Writes Event protocol buffers to event files.
|
||
|
withEventWriter :: (MonadIO m, MonadMask m) => FilePath -> (EventWriter -> m a) -> m a
|
||
|
|
||
|
-- | Logs the given Event protocol buffer.
|
||
|
logEvent :: MonadIO m => EventWriter -> Event -> m ()
|
||
|
|
||
|
-- | Logs the given Summary event with an optional global step (use 0 if
|
||
|
-- not applicable).
|
||
|
logSummary :: MonadIO m => EventWriter -> Int64 -> Summary -> m ()
|
||
|
|
||
|
-- | Synonym for the tensors that return serialized Summary proto.
|
||
|
type SummaryTensor = Tensor Value ByteString
|
||
|
|
||
|
-- | Adds a <a>histogramSummary</a> node. The tag argument is intentionally
|
||
|
-- limited to a single value for simplicity.
|
||
|
histogramSummary :: (MonadBuild m, TensorType t, t /= ByteString, t /= Bool) => ByteString -> Tensor v t -> m ()
|
||
|
|
||
|
-- | Adds a <a>scalarSummary</a> node.
|
||
|
scalarSummary :: (TensorType t, t /= ByteString, t /= Bool, MonadBuild m) => ByteString -> Tensor v t -> m ()
|
||
|
|
||
|
-- | Merge all summaries accumulated in the <tt>Build</tt> into one
|
||
|
-- summary.
|
||
|
mergeAllSummaries :: MonadBuild m => m SummaryTensor
|