| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
RL.TorchHelpers
Synopsis
- data SumAll = SumAll
- data Add = Add
- newtype Mul num = Mul num
- newtype Mul' (dev :: (DeviceType, Nat)) (dtype :: DType) = Mul' (Tensor dev dtype ('[] :: [Nat]))
- detach :: forall (dev :: (DeviceType, Nat)) (dtype :: DType) (shape :: [Nat]). Tensor dev dtype shape -> IO (Tensor dev dtype shape)
- data Detach = Detach
- newtype Interpolate num = Interpolate num
- data ShapeVal = ShapeVal
- data ToList = ToList
- type family ToModelTensors (params :: [Type]) :: [Type] where ...
- withBatchDim :: forall (dev1 :: (DeviceType, Nat)) (dtype1 :: DType) (shape1 :: [Natural]) (dev2 :: (DeviceType, Nat)) (dtype2 :: DType) (shape2 :: [Natural]). (Tensor dev1 dtype1 (1 ': shape1) -> Tensor dev2 dtype2 (1 ': shape2)) -> Tensor dev1 dtype1 shape1 -> Tensor dev2 dtype2 shape2
- conv2dRelaxed :: forall (stride :: (Nat, Nat)) (padding :: (Nat, Nat)) (inputChannelSize :: Nat) (outputChannelSize :: Nat) (kernelSize0 :: Nat) (kernelSize1 :: Nat) (inputSize0 :: Nat) (inputSize1 :: Nat) (batchSize :: Nat) (outputSize0 :: Nat) (outputSize1 :: Nat) (dtype :: DType) (device :: (DeviceType, Nat)). (All KnownNat '[Fst stride, Snd stride, Fst padding, Snd padding], ConvSideCheck inputSize0 kernelSize0 (Fst stride) (Fst padding) outputSize0, ConvSideCheck inputSize1 kernelSize1 (Snd stride) (Snd padding) outputSize1) => Tensor device dtype '[outputChannelSize, inputChannelSize, kernelSize0, kernelSize1] -> Tensor device dtype '[outputChannelSize] -> Tensor device dtype '[batchSize, inputChannelSize, inputSize0, inputSize1] -> Tensor device dtype '[batchSize, outputChannelSize, outputSize0, outputSize1]
- conv2dForwardRelaxed :: forall (stride :: (Nat, Nat)) (padding :: (Nat, Nat)) (inputChannelSize :: Nat) (outputChannelSize :: Nat) (kernelSize0 :: Nat) (kernelSize1 :: Nat) (inputSize0 :: Nat) (inputSize1 :: Nat) (batchSize :: Nat) (outputSize0 :: Nat) (outputSize1 :: Nat) (dtype :: DType) (device :: (DeviceType, Nat)). (All KnownNat '[Fst stride, Snd stride, Fst padding, Snd padding], ConvSideCheck inputSize0 kernelSize0 (Fst stride) (Fst padding) outputSize0, ConvSideCheck inputSize1 kernelSize1 (Snd stride) (Snd padding) outputSize1) => Conv2d inputChannelSize outputChannelSize kernelSize0 kernelSize1 dtype device -> Tensor device dtype '[batchSize, inputChannelSize, inputSize0, inputSize1] -> Tensor device dtype '[batchSize, outputChannelSize, outputSize0, outputSize1]
Documentation
Helper Type to map sumAll over a HList.
Constructors
| SumAll |
Helper Type to fold a HList by adding the values.
Constructors
| Add |
Instances
| (BasicArithmeticDTypeIsValid dev dtype, CheckBroadcast shape1 shape2 (ComputeBroadcast (ReverseImpl shape1 ('[] :: [Nat])) (ReverseImpl shape2 ('[] :: [Nat]))) ~ shapeOut) => Apply' Add (Tensor dev dtype shape1, Tensor dev dtype shape2) (Tensor dev dtype shapeOut) Source # | |
Helper Type to multiply a HList with a scalar
Constructors
| Mul num |
detach :: forall (dev :: (DeviceType, Nat)) (dtype :: DType) (shape :: [Nat]). Tensor dev dtype shape -> IO (Tensor dev dtype shape) Source #
Detach a typed tensor.
newtype Interpolate num Source #
Helper Type for interpolating qnet parameters.
Constructors
| Interpolate num |
Instances
| (Scalar num, Num num, BasicArithmeticDTypeIsValid dev dtype, CheckBroadcast shape shape (ComputeBroadcast (ReverseImpl shape ('[] :: [Nat])) (ReverseImpl shape ('[] :: [Nat]))) ~ shape) => Apply' (Interpolate num) (Tensor dev dtype shape, Tensor dev dtype shape) (Tensor dev dtype shape) Source # | |
Defined in RL.TorchHelpers | |
Helper Type for getting the number of parameters in a model
Constructors
| ShapeVal |
Helper Type for getting a list out of a HList
Constructors
| ToList |
type family ToModelTensors (params :: [Type]) :: [Type] where ... Source #
Equations
| ToModelTensors ('[] :: [Type]) = '[] :: [Type] | |
| ToModelTensors (Parameter dev dtype shape ': rst) = Tensor dev dtype shape ': ToModelTensors rst |
withBatchDim :: forall (dev1 :: (DeviceType, Nat)) (dtype1 :: DType) (shape1 :: [Natural]) (dev2 :: (DeviceType, Nat)) (dtype2 :: DType) (shape2 :: [Natural]). (Tensor dev1 dtype1 (1 ': shape1) -> Tensor dev2 dtype2 (1 ': shape2)) -> Tensor dev1 dtype1 shape1 -> Tensor dev2 dtype2 shape2 Source #
Run a batched operation in an unbatched context
Arguments
| :: forall (stride :: (Nat, Nat)) (padding :: (Nat, Nat)) (inputChannelSize :: Nat) (outputChannelSize :: Nat) (kernelSize0 :: Nat) (kernelSize1 :: Nat) (inputSize0 :: Nat) (inputSize1 :: Nat) (batchSize :: Nat) (outputSize0 :: Nat) (outputSize1 :: Nat) (dtype :: DType) (device :: (DeviceType, Nat)). (All KnownNat '[Fst stride, Snd stride, Fst padding, Snd padding], ConvSideCheck inputSize0 kernelSize0 (Fst stride) (Fst padding) outputSize0, ConvSideCheck inputSize1 kernelSize1 (Snd stride) (Snd padding) outputSize1) | |
| => Tensor device dtype '[outputChannelSize, inputChannelSize, kernelSize0, kernelSize1] | weight |
| -> Tensor device dtype '[outputChannelSize] | bias |
| -> Tensor device dtype '[batchSize, inputChannelSize, inputSize0, inputSize1] | input |
| -> Tensor device dtype '[batchSize, outputChannelSize, outputSize0, outputSize1] | output |
conv2d with dropped batch size constraint
conv2dForwardRelaxed :: forall (stride :: (Nat, Nat)) (padding :: (Nat, Nat)) (inputChannelSize :: Nat) (outputChannelSize :: Nat) (kernelSize0 :: Nat) (kernelSize1 :: Nat) (inputSize0 :: Nat) (inputSize1 :: Nat) (batchSize :: Nat) (outputSize0 :: Nat) (outputSize1 :: Nat) (dtype :: DType) (device :: (DeviceType, Nat)). (All KnownNat '[Fst stride, Snd stride, Fst padding, Snd padding], ConvSideCheck inputSize0 kernelSize0 (Fst stride) (Fst padding) outputSize0, ConvSideCheck inputSize1 kernelSize1 (Snd stride) (Snd padding) outputSize1) => Conv2d inputChannelSize outputChannelSize kernelSize0 kernelSize1 dtype device -> Tensor device dtype '[batchSize, inputChannelSize, inputSize0, inputSize1] -> Tensor device dtype '[batchSize, outputChannelSize, outputSize0, outputSize1] Source #