Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues of observation_space and action_space of costumed environment #19

Open
hrjtju opened this issue Aug 19, 2024 · 0 comments
Open

Comments

@hrjtju
Copy link

hrjtju commented Aug 19, 2024

Python version: 3.10.14
joyrl version: 0.6.5.1
Pytorch version: torch 2.2.1+cu121
torchaudio 2.2.1+cu121
torchvision 0.17.1+cu121

I intend to define observation space as follows:
[Image_of_one_channel, 1d-vector, 1d-vector]
And output space as follows:
[1d-vector]

For the observation spaces, I defined it as follows:

self.observation_space = spaces.Tuple(spaces=[
    spaces.Box(low=0, high=float("inf"), shape=(1, N, N)),
    spaces.Box(low=0, high=float("inf"), shape=(A,)),
    spaces.Box(low=0, high=float("inf"), shape=(B, ))
])
self.action_space = spaces.Box(low=0, high=float("inf"), shape=(B, 1))

in which capitalized letters represent numbers. But I notice that functions for spaces.Tuple is not yet implemented, as shown below:

# run.py, class Launcher
...
    def _check_obs_action_space_info(self, env):
        obs_space = env.observation_space
        if isinstance(obs_space, Box):
            if len(obs_space.shape) == 3:
                state_type_list = [ObsType.IMAGE]
                state_size_list = [[obs_space.shape[0], obs_space.shape[1], obs_space.shape[2]]]
            else:
                state_type_list = [ObsType.VECTOR]
                state_size_list = [[obs_space.shape[0]]]
        elif isinstance(obs_space, Discrete):
            state_type_list = [ObsType.VECTOR]
            state_size_list = [[obs_space.n]]
        else:
            raise ValueError('obs_space type error')
...

The second problem arises when I try to assign action space to continuous vector in $\mathbf{R}^k$ but I didn't save the error log. In general, the action layers is parsed to have the last layer with output shape 0, and raise the error. When I tried to modify the source code to force it not be 0, other errors ocurrs.

Finally, the corresponding network architecture field in the .yaml file is

algo_cfg:
  branch_layers:
    - name: view
      layers:
      - layer_type: conv2d
        in_channel: 1
        out_channel: 16 
        kernel_size: 4
        stride: 2
        activation: relu
      - layer_type: pooling
        pooling_type: max2d
        kernel_size: 2
        stride: 2
        padding: 0
      - layer_type: flatten
      - layer_type: norm
        norm_type: LayerNorm
        normalized_shape: 512
      - layer_type: linear
        layer_size: [128]
        activation: relu
    - name: lwh
      layers:
      - layer_type: linear
        layer_size: [32]
        activation: relu
      - layer_type: linear
        layer_size: [32]
        activation: relu
    - name: parts
      layers:
      - layer_type: linear
        layer_size: [256]
        activation: relu
      - layer_type: linear
        layer_size: [256]
        activation: relu
  merge_layers:
    - layer_type: linear
      layer_size: [256]
      activation: relu
    - layer_type: linear
      layer_size: [256]
      activation: relu
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant