Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utility and Helper functions for EDELWACE
Synopsis
- data Algorithm
- foldLoop' :: Int -> (a -> Int -> IO a) -> a -> IO a
- nanToNum :: Float -> Float -> Float -> Tensor -> Tensor
- nanToNum' :: Tensor -> Tensor
- nanToNum'' :: Tensor -> Tensor
- fullLike' :: Tensor -> Float -> Tensor
- indexSelect'' :: Int -> [Int] -> Tensor -> Tensor
- where'' :: Tensor -> (Tensor -> Tensor) -> Tensor -> Tensor
- repeatInterleave' :: Int -> Tensor -> Tensor -> Tensor
- both :: (a -> b) -> Either a a -> b
- both' :: (a -> b) -> Either a a -> Either b b
- range :: Int -> [Int]
- fst' :: (a, b, c) -> a
- splits :: [Int] -> [[Int]]
- splits' :: [Int] -> [Tensor]
- splitDim :: Int -> Tensor -> [Tensor]
- currentTimeStamp :: String -> IO String
- currentTimeStamp' :: IO String
- createModelArchiveDir :: String -> IO String
- saveOptim :: Adam -> FilePath -> IO ()
- loadOptim :: Int -> Float -> Float -> FilePath -> IO Adam
- weightLimit :: Linear -> Float
- data Initializer
- initWeights :: Initializer -> Float -> Float -> [Int] -> IO IndependentTensor
- weightInit :: Initializer -> Float -> Float -> Linear -> IO Linear
- weightInit' :: Initializer -> Float -> Float -> Linear -> IO Linear
- weightInitUniform :: Float -> Float -> Linear -> IO Linear
- weightInitUniform' :: Linear -> IO Linear
- weightInitNormal :: Float -> Float -> Linear -> IO Linear
- weightInitNormal' :: Linear -> IO Linear
- softUpdate :: Tensor -> Tensor -> Tensor -> Tensor
- softSync :: Parameterized f => Tensor -> f -> f -> IO f
- copySync :: Parameterized f => f -> f -> f
- gpu :: Device
- cpu :: Device
- dataType :: DType
- toTensor :: TensorLike a => a -> Tensor
- toTensor' :: TensorLike a => a -> Tensor
- toIntTensor :: TensorLike a => a -> Tensor
- toIntTensor' :: TensorLike a => a -> Tensor
- emptyTensor :: Tensor
- emptyTensor' :: Tensor
- toScalar :: Float -> Tensor
- toScalar' :: Float -> Tensor
- toDoubleGPU :: forall a. HasTypes a Tensor => a -> a
- toDoubleGPU' :: forall a. HasTypes a Tensor => a -> a
- toFloatGPU :: forall a. HasTypes a Tensor => a -> a
- toFloatCPU :: forall a. HasTypes a Tensor => a -> a
- randomInts :: Int -> Int -> Int -> IO Tensor
- randomInts' :: Int -> Int -> Int -> IO Tensor
- normal' :: [Int] -> IO Tensor
- normal :: Tensor -> Tensor -> IO Tensor
- uniform' :: [Int] -> Float -> Float -> IO Tensor
- rescale :: Tensor -> Tensor
- httpOptions :: Options
- data Info = Info {
- observations :: ![String]
- actions :: ![String]
- data Step = Step {}
- type HymURL = String
- data ActionSpace
- mapToTensor :: Map Int [Float] -> Tensor
- mapToTensor' :: Map Int [Float] -> Tensor
- tensorToMap :: Tensor -> Map Int [Float]
- tensorToMap' :: Tensor -> Map Int Int
- stepsToTuple :: Map Int Step -> (Tensor, Tensor, Tensor, [Info])
- stepsToTuple' :: Map Int Step -> (Tensor, Tensor, Tensor, [Info])
- hymGet :: HymURL -> String -> IO ByteString
- hymPost :: HymURL -> String -> Value -> IO ByteString
- hymPoolMap :: HymURL -> String -> IO (Map Int (Map String Float))
- hymPoolMap' :: HymURL -> String -> IO (Map Int (Map String Bool))
- hymPoolList :: HymURL -> String -> IO (Map Int [Float])
- hymPoolList' :: HymURL -> String -> IO (Map Int [String])
- hymPoolReset :: HymURL -> IO (Map Int [Float])
- hymPoolRandomAction :: HymURL -> IO (Map Int [Float])
- hymPoolRandomStep :: HymURL -> IO (Map Int Step)
- hymPoolStep :: HymURL -> Map Int [Float] -> IO (Map Int Step)
- hymPoolStep' :: HymURL -> Map Int Int -> IO (Map Int Step)
- aceURL :: String -> String -> String -> String -> String -> HymURL
- gymURL :: String -> String -> String -> String -> HymURL
- acePoolTarget :: HymURL -> IO (Map Int (Map String Float))
- acePoolPredicate :: HymURL -> IO (Map Int (Map String Bool))
- acePoolScaler :: HymURL -> IO (Map Int (Map String [Float]))
- acePoolActKeys :: HymURL -> IO (Map Int [String])
- acePoolObsKeys :: HymURL -> IO (Map Int [String])
- shaceLogPath' :: HymURL -> IO (Map String String)
- shaceLogPath :: HymURL -> IO String
- resetPool :: HymURL -> IO Tensor
- resetPool' :: HymURL -> Tensor -> IO Tensor
- actKeysPool :: HymURL -> IO [String]
- obsKeysPool :: HymURL -> IO [String]
- numEnvsPool :: HymURL -> IO Int
- infoPool :: HymURL -> IO Info
- targetPool :: HymURL -> IO Tensor
- targetPool' :: HymURL -> IO Tensor
- targetKeysPool :: HymURL -> IO [String]
- scalerPool :: HymURL -> [String] -> IO Tensor
- scalerPool' :: HymURL -> IO Tensor
- stepPool :: HymURL -> Tensor -> IO (Tensor, Tensor, Tensor, [Info])
- stepPool' :: HymURL -> Tensor -> IO (Tensor, Tensor, Tensor, [Info])
- randomStepPool :: HymURL -> IO (Tensor, Tensor, Tensor, [Info])
- randomActionPool :: HymURL -> IO Tensor
- boolMask :: Int -> [Int] -> Tensor
- boolMask'' :: Int -> [Int] -> Tensor
- boolMask' :: Int -> Tensor -> Tensor
- processTarget :: Map Int (Map String Float) -> Tensor
- postProcess' :: Map String [Float] -> (Tensor, Tensor, Tensor, [Info]) -> (Tensor, Tensor, Tensor, Tensor, Tensor)
- postProcess :: Info -> Map String [Float] -> Tensor -> (Tensor, Tensor, Tensor)
- processGace'' :: Tensor -> Info -> (Tensor, Tensor, Tensor)
- processGace' :: Tensor -> Info -> Tensor
- processGace :: Tensor -> Info -> Tensor
- scaleRewards :: Tensor -> Float -> Tensor
- normalize :: Float -> Float -> Tensor -> Tensor
- normalize' :: Tensor -> Tensor
- normalize'' :: Float -> Float -> Tensor -> Tensor -> Tensor -> Tensor
- denormalize :: Tensor -> Tensor -> Tensor -> Tensor
- sanatizeJSON :: Char -> Char
- data Tracker = Tracker {
- uri :: TrackingURI
- experimentId :: ExperimentID
- experimentName :: String
- runIds :: Map String RunID
- runId :: Tracker -> String -> RunID
- mkTracker :: TrackingURI -> String -> IO Tracker
- mkTracker' :: String -> Int -> String -> IO Tracker
- newExperiment :: Tracker -> String -> IO Tracker
- newExperiment' :: Tracker -> String -> IO Tracker
- newRuns :: Tracker -> [String] -> [Param] -> IO Tracker
- newRuns' :: Int -> Tracker -> IO Tracker
- endRun :: String -> Tracker -> IO Tracker
- endRuns :: Tracker -> IO Tracker
- endRuns' :: Tracker -> IO ()
- trackLoss :: Tracker -> Int -> String -> Float -> IO (Response ByteString)
- trackReward :: Tracker -> Int -> Tensor -> IO ()
- filterPerformance :: Map Int (Map String Float) -> [String] -> Map Int (Map String Float)
- trackEnvState :: Tracker -> HymURL -> Int -> IO ()
Documentation
Deep Reinforcement Learning Algorithm
SAC | Soft Actor-Critic |
TD3 | Twin Delayed Deep Deterministic Policy Gradient |
PPO | Proximal Policy Optimization |
foldLoop' :: Int -> (a -> Int -> IO a) -> a -> IO a Source #
Swaps the arguments of HaskTorch's foldLoop around
where'' :: Tensor -> (Tensor -> Tensor) -> Tensor -> Tensor Source #
Torch.where' with fixed type for where'
repeatInterleave' :: Int -> Tensor -> Tensor -> Tensor Source #
Syntactic sugar for HaskTorch's repeatInterleave
so it can more easily
be fmapped.
both' :: (a -> b) -> Either a a -> Either b b Source #
Apply same function to both Left and Right and put back into Either
currentTimeStamp' :: IO String Source #
Current Timestamp with default formatting: "%Y%m%d-%H%M%S"
createModelArchiveDir :: String -> IO String Source #
Create a model archive directory for the given algorithm
weightLimit :: Linear -> Float Source #
Calculate weight Limits based on Layer Dimensions
data Initializer Source #
Type of weight initialization
Normal | Normally distributed weights |
Uniform | Uniformally distributed weights |
XavierNormal | Using T.xavierNormal |
XavierUniform | Using T.xavierUniform |
KaimingNormal | Using T.kaimingNormal |
KaimingUniform | Using T.kaimingUniform |
Dirac | |
Eye | |
Ones | |
Zeros | |
Constant |
initWeights :: Initializer -> Float -> Float -> [Int] -> IO IndependentTensor Source #
Weights for a layer given limits and dimensions.
weightInit :: Initializer -> Float -> Float -> Linear -> IO Linear Source #
Initialize Weights of Linear Layer
weightInit' :: Initializer -> Float -> Float -> Linear -> IO Linear Source #
Initialize Weights and Bias of Linear Layer
weightInitUniform :: Float -> Float -> Linear -> IO Linear Source #
Initialize weights uniformally given upper and lower bounds
weightInitNormal :: Float -> Float -> Linear -> IO Linear Source #
Initialize weights normally given mean and std bounds
softUpdate :: Tensor -> Tensor -> Tensor -> Tensor Source #
Softly update parameters from Online Net to Target Net
softSync :: Parameterized f => Tensor -> f -> f -> IO f Source #
Softly copy parameters from Online Net to Target Net
copySync :: Parameterized f => f -> f -> f Source #
Hard Copy of Parameter from one net to the other
toTensor :: TensorLike a => a -> Tensor Source #
Convert an Array to a Tensor on GPU
toTensor' :: TensorLike a => a -> Tensor Source #
Convert an Array to a Tensor on CPU
toIntTensor :: TensorLike a => a -> Tensor Source #
Convert an Array to a Tensor on GPU
toIntTensor' :: TensorLike a => a -> Tensor Source #
Convert an Array to a Tensor on CPU
emptyTensor :: Tensor Source #
Create an empty Float Tensor on GPU
emptyTensor' :: Tensor Source #
Create an empty Float Tensor on CPU
toDoubleGPU :: forall a. HasTypes a Tensor => a -> a Source #
Convert model to Double on GPU
toDoubleGPU' :: forall a. HasTypes a Tensor => a -> a Source #
Convert model to Double on CPU
toFloatGPU :: forall a. HasTypes a Tensor => a -> a Source #
Convert model to Float on CPU
toFloatCPU :: forall a. HasTypes a Tensor => a -> a Source #
Convert model to Float on CPU
normal :: Tensor -> Tensor -> IO Tensor Source #
Generate Normally Distributed Random values given μs and σs
uniform' :: [Int] -> Float -> Float -> IO Tensor Source #
Generate Uniformally distributed values in a given range
httpOptions :: Options Source #
HTTP options for Hym server communication, sometimes simulations can take a while, therefore we wait ...
Info object gotten form stepping
Info | |
|
Instances
Show Info Source # | |
Generic Info Source # | |
ToJSON Info Source # | |
FromJSON Info Source # | |
type Rep Info Source # | |
Defined in Lib type Rep Info = D1 ('MetaData "Info" "Lib" "edelwace-0.1.0.0-NlkYKOSwr4E6F4MQQAmdJ" 'False) (C1 ('MetaCons "Info" 'PrefixI 'True) (S1 ('MetaSel ('Just "observations") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [String]) :*: S1 ('MetaSel ('Just "actions") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [String]))) |
Single Environment Step
Instances
Show Step Source # | |
Generic Step Source # | |
ToJSON Step Source # | |
FromJSON Step Source # | |
type Rep Step Source # | |
Defined in Lib type Rep Step = D1 ('MetaData "Step" "Lib" "edelwace-0.1.0.0-NlkYKOSwr4E6F4MQQAmdJ" 'False) (C1 ('MetaCons "Step" 'PrefixI 'True) ((S1 ('MetaSel ('Just "observation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Float]) :*: S1 ('MetaSel ('Just "reward") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Float)) :*: (S1 ('MetaSel ('Just "done") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Info)))) |
data ActionSpace Source #
Possible Action Spaces
Continuous | Continuous Action Space |
Discrete | Discrete Action Space |
Instances
Eq ActionSpace Source # | |
Defined in Lib (==) :: ActionSpace -> ActionSpace -> Bool # (/=) :: ActionSpace -> ActionSpace -> Bool # | |
Show ActionSpace Source # | |
Defined in Lib showsPrec :: Int -> ActionSpace -> ShowS # show :: ActionSpace -> String # showList :: [ActionSpace] -> ShowS # |
mapToTensor :: Map Int [Float] -> Tensor Source #
Convert a Map to a Tensor where Pool index is a dimension on GPU
mapToTensor' :: Map Int [Float] -> Tensor Source #
Convert a Map to a Tensor where Pool index is a dimension on CPU
tensorToMap :: Tensor -> Map Int [Float] Source #
Convert Tensor to Map (Continuous action spaces) on GPU
stepsToTuple :: Map Int Step -> (Tensor, Tensor, Tensor, [Info]) Source #
Convert the Pooled Step Map to a Tuple on GPU
stepsToTuple' :: Map Int Step -> (Tensor, Tensor, Tensor, [Info]) Source #
Convert the Pooled Step Map to a Tuple on CPU
hymPoolMap :: HymURL -> String -> IO (Map Int (Map String Float)) Source #
Convert a JSON Response from an ACE Server to a Map: String Float
hymPoolMap' :: HymURL -> String -> IO (Map Int (Map String Bool)) Source #
Convert a JSON Response from an ACE Server to a Map: String Bool
hymPoolList :: HymURL -> String -> IO (Map Int [Float]) Source #
Convert a JSON Response from an ACE Server to a Float-List
hymPoolList' :: HymURL -> String -> IO (Map Int [String]) Source #
Convert a JSON Response from an ACE Server to a String-List
hymPoolRandomAction :: HymURL -> IO (Map Int [Float]) Source #
Get Random Actions from all Pooled Environments
hymPoolRandomStep :: HymURL -> IO (Map Int Step) Source #
Perform Random Actions in all Pooled Environments
hymPoolStep :: HymURL -> Map Int [Float] -> IO (Map Int Step) Source #
Take Steps in All Environments (Continuous)
hymPoolStep' :: HymURL -> Map Int Int -> IO (Map Int Step) Source #
Take Steps in All Environments (Discrete)
aceURL :: String -> String -> String -> String -> String -> HymURL Source #
Generate URL to a Hym-GACE server from meta information
gymURL :: String -> String -> String -> String -> HymURL Source #
Generate URL to a Hym-Gym server from meta information
acePoolTarget :: HymURL -> IO (Map Int (Map String Float)) Source #
Send a GET Request to a GACE Server Obtain the Target of Pooled GACE Environments
acePoolPredicate :: HymURL -> IO (Map Int (Map String Bool)) Source #
Send a GET Request to a GACE Server Obtain the Target Predicate of Pooled GACE Environments
acePoolScaler :: HymURL -> IO (Map Int (Map String [Float])) Source #
Get minmax estimates for performances andor targets
scalerPool :: HymURL -> [String] -> IO Tensor Source #
Implying same target params for all envs in pool.
scalerPool' :: HymURL -> IO Tensor Source #
Implying same target params for all envs in pool and we want all of them.
stepPool :: HymURL -> Tensor -> IO (Tensor, Tensor, Tensor, [Info]) Source #
Step in a Control Environment
stepPool' :: HymURL -> Tensor -> IO (Tensor, Tensor, Tensor, [Info]) Source #
Step in a Discrete Environment
randomStepPool :: HymURL -> IO (Tensor, Tensor, Tensor, [Info]) Source #
Take a random Step an Environment
randomActionPool :: HymURL -> IO Tensor Source #
Get a set of random actions from the current environment
boolMask'' :: Int -> [Int] -> Tensor Source #
Create Boolean Mask Tensor from list of indices on CPU.
postProcess' :: Map String [Float] -> (Tensor, Tensor, Tensor, [Info]) -> (Tensor, Tensor, Tensor, Tensor, Tensor) Source #
Convenience, takes output straight from stepPool
.
postProcess :: Info -> Map String [Float] -> Tensor -> (Tensor, Tensor, Tensor) Source #
Process for HER returns processed observations, the target and the augmented target
processGace'' :: Tensor -> Info -> (Tensor, Tensor, Tensor) Source #
Process for HER returns processed observations, the target and the augmented target
normalize' :: Tensor -> Tensor Source #
Convenience: Normalize feature x s.t. x' ∈ [-1.0,1.0]
normalize'' :: Float -> Float -> Tensor -> Tensor -> Tensor -> Tensor Source #
Normalize given some arbitrary min / max values
denormalize :: Tensor -> Tensor -> Tensor -> Tensor Source #
Normalize feature x' ∈ [a,b] given the original min/max
sanatizeJSON :: Char -> Char Source #
Sanatize JSON for MLFlow: Names may only contain alphanumerics, underscores (_), dashes (-), periods (.), spaces ( ), and slashes (/).
Data Logging to MLFlow Trackign Server
Tracker | |
|
mkTracker :: TrackingURI -> String -> IO Tracker Source #
Make new Tracker given a Tracking Server URI
mkTracker' :: String -> Int -> String -> IO Tracker Source #
Make new Tracker given a Hostname and Port
newRuns :: Tracker -> [String] -> [Param] -> IO Tracker Source #
Create a new run with a set of given paramters
trackLoss :: Tracker -> Int -> String -> Float -> IO (Response ByteString) Source #
Write Loss to Tracking Server