Collector

public struct Collector<Element: TensorNumeric, StateType, EnvType: Env, EnvElement: TensorNumeric>
where EnvType.ObsType == Tensor<EnvElement>, EnvType.ActType == Tensor<EnvElement>

The helper to collect data from the given Envs.

The policy is intentional to be flexible as a simple closure. We collect both the action and state data the closure provides. There may be some type conversions for what the Env expects and what the policy provides, thus, need to specify both. To make this easier to use, the placeholder type would be useful: Collector<Float, (), _, _>(envs: envs) { ... }

  • Declaration

    Swift

    public typealias ObsType = Tensor<Element>
  • Declaration

    Swift

    public typealias ActType = Tensor<Element>
  • Declaration

    Swift

    public init(envs: [EnvType], policy: @escaping (ObsType) -> (ActType, StateType))
  • Declaration

    Swift

    public struct Statistics
  • Declaration

    Swift

    public mutating func resetData(keepLastN: Int = 0)
  • Declaration

    Swift

    public mutating func reset()
  • Declaration

    Swift

    public var data: [CollectedData<Element, StateType>] { get }

Available where EnvType.TerminatedType == Bool, EnvType.RewardType == Float