docs.unity3d.com
    Show / Hide Table of Contents

    Struct CompressionSpec

    A description of the compression used for observations.

    Namespace: Unity.MLAgents.Sensors
    Syntax
    public struct CompressionSpec
    Remarks

    Most ISensor implementations can't take advantage of compression, and should return CompressionSpec.Default() from their ISensor.GetCompressionSpec() methods. Visual observations, or mulitdimensional categorical observations (for example, image segmentation or the piece types in a match-3 game board) can use PNG compression reduce the amount of data transferred between Unity and the trainer.

    Constructors

    CompressionSpec(SensorCompressionType, Int32[])

    Return a CompressionSpec indicating possible compression.

    Declaration
    public CompressionSpec(SensorCompressionType sensorCompressionType, int[] compressedChannelMapping = null)
    Parameters
    Type Name Description
    SensorCompressionType sensorCompressionType

    The compression type to use.

    Int32[] compressedChannelMapping

    Optional mapping mapping of the channels in compressed data to the actual channel after decompression.

    Properties

    CompressedChannelMapping

    The mapping of the channels in compressed data to the actual channel after decompression.

    Declaration
    public int[] CompressedChannelMapping { get; }
    Property Value
    Type Description
    Int32[]
    Remarks

    The mapping is a list of integer index with the same length as the number of output observation layers (channels), including padding if there's any. Each index indicates the actual channel the layer will go into. Layers with the same index will be averaged, and layers with negative index will be dropped. For example, mapping for CameraSensor using grayscale and stacking of two: [0, 0, 0, 1, 1, 1] Mapping for GridSensor of 4 channels and stacking of two: [0, 1, 2, 3, -1, -1, 4, 5, 6, 7, -1, -1]

    SensorCompressionType

    The compression type that the sensor will use for its observations.

    Declaration
    public SensorCompressionType SensorCompressionType { get; }
    Property Value
    Type Description
    SensorCompressionType

    Methods

    Default()

    Return a CompressionSpec indicating no compression. This is recommended for most sensors.

    Declaration
    public static CompressionSpec Default()
    Returns
    Type Description
    CompressionSpec
    In This Article
    • Constructors
      • CompressionSpec(SensorCompressionType, Int32[])
    • Properties
      • CompressedChannelMapping
      • SensorCompressionType
    • Methods
      • Default()
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023