UnsqueezeTransform¶
- class torchrl.envs.transforms.UnsqueezeTransform(*args, **kwargs)[來源]¶
在指定位置插入大小為 1 的維度。
- 參數:
dim (int) – 要 unsqueeze 的維度。必須為負數(或必須開啟 allow_positive_dim)。
- 關鍵字參數:
allow_positive_dim (bool, optional) – 如果
True
,則接受正維度。UnsqueezeTransform` 會將這些維度對應到輸入張量的第 n 個特徵維度(即父環境批量大小之後的第 n 個維度),獨立於 tensordict 批量大小(即正維度在傳遞不同批量維度的 tensordict 的情況下可能很危險)。預設為 False,即不允許非負維度。in_keys (NestedKeys 列表) – 輸入項目(讀取)。
out_keys (NestedKeys 列表) – 輸入項目(寫入)。如果未提供,則預設為
in_keys
。in_keys_inv (NestedKeys 列表) – 在
inv()
呼叫期間的輸入項目(讀取)。out_keys_inv (NestedKeys 列表) – 在
inv()
呼叫期間的輸入項目(寫入)。如果未提供,則預設為in_keys_in
。
- transform_input_spec(input_spec)[來源]¶
轉換輸入規格,使結果規格與轉換對應匹配。
- 參數:
input_spec (TensorSpec) – 轉換前的規格
- 傳回值:
轉換後的預期規格
- transform_observation_spec(observation_spec: TensorSpec) TensorSpec [來源]¶
轉換觀察規格,使結果規格與轉換對應匹配。
- 參數:
observation_spec (TensorSpec) – 轉換前的規格
- 傳回值:
轉換後的預期規格
- transform_reward_spec(reward_spec: TensorSpec) TensorSpec [原始碼]¶
轉換獎勵規格 (reward spec),使產生的規格與轉換映射 (transform mapping) 相符。
- 參數:
reward_spec (TensorSpec) – 轉換前的規格
- 傳回值:
轉換後的預期規格