UnsqueezeTransform¶
- 類 torchrl.envs.transforms.UnsqueezeTransform(*args, **kwargs)[原始碼]¶
在指定位置插入一個大小為 1 的維度。
- 引數:
dim (int) – 要插入維度的位置。必須是負數(或者 allow_positive_dim 必須設定為 True)。
- 關鍵字引數:
allow_positive_dim (bool, optional) – 如果為
True,則接受正維度。 UnsqueezeTransform` 會將這些維度對映到輸入張量的第 n 個特徵維度(即父環境批處理大小之後的第 n 個維度),與 tensordict 的批處理大小無關(即正維度在傳遞不同批處理大小的 tensordict 的上下文中可能很危險)。預設為 False,即不允許非負維度。in_keys (list of NestedKeys) – 輸入條目(讀取)。
out_keys (list of NestedKeys) – 輸入條目(寫入)。如果未提供,則預設為
in_keys。in_keys_inv (list of NestedKeys) – 在
inv()呼叫期間的輸入條目(讀取)。out_keys_inv (list of NestedKeys) – 在
inv()呼叫期間的輸入條目(寫入)。如果未提供,則預設為in_keys_inv。
- transform_action_spec(action_spec: TensorSpec) TensorSpec[原始碼]¶
轉換 action spec,使其結果 spec 與 transform 對映匹配。
- 引數:
action_spec (TensorSpec) – transform 之前的 spec
- 返回:
transform 之後的預期 spec
- transform_observation_spec(observation_spec: TensorSpec) TensorSpec[原始碼]¶
轉換 observation spec,使其結果 spec 與 transform 對映匹配。
- 引數:
observation_spec (TensorSpec) – transform 之前的 spec
- 返回:
transform 之後的預期 spec
- transform_reward_spec(reward_spec: TensorSpec) TensorSpec[原始碼]¶
轉換 reward spec,使其結果 spec 與 transform 對映匹配。
- 引數:
reward_spec (TensorSpec) – transform 之前的 spec
- 返回:
transform 之後的預期 spec
- transform_state_spec(state_spec: TensorSpec) TensorSpec[原始碼]¶
轉換 state spec,使其結果 spec 與 transform 對映匹配。
- 引數:
state_spec (TensorSpec) – transform 之前的 spec
- 返回:
transform 之後的預期 spec