danijar / dreamerv3

Mastering Diverse Domains through World Models
https://danijar.com/dreamerv3
MIT License
1.36k stars 229 forks source link

DreamerV3-Obstacle Tower #96

Closed vaggelisT closed 6 months ago

vaggelisT commented 1 year ago

I'm trying to integrate the Dreamerv3 algorithm into the Obstacle Tower game via example.py without any success so far . The error i get is: Error p TypeError: dot_general requires contracting dimensions to have the same shape, got (1078,) and (1041,). INFO:mlagents_envs.environment:Environment shut down with return code 0.

The changes I've made so far are:

  1. In the dreamerv3/nets.py file I added the code: stages = int(np.ceil(np.log2(self._shape[-2]) - np.log2(self._minres)))

  2. In example.py file i replaced the crafter environment with the obstacle tower: from obstacle_tower_env import ObstacleTowerEnv from embodied.envs import from_gym env = ObstacleTowerEnv(retro=False, realtime_mode=False) env = from_gym.FromGym(env, obs_key='image') # Or obs_key='vector'. print(env.act_space) env = dreamerv3.wrap_env(env, config) env = embodied.BatchEnv([env], parallel=False)

3.Α. In the from_gym.py file I have changed the following function: def _flatten(self, nest, prefix=None): result = {} # for key, value in nest.items(): # key = prefix + '/' + key if prefix else key # if isinstance(value, gym.spaces.Dict): # value = value.spaces # if isinstance(value, dict): # result.update(self._flatten(value, key)) # else: # result[key] = value print(nest) result["image"] = nest[0 ] result["keys"] = nest[1] result["time"] = nest[2] result["floor"] = nest[3] return result

3.Β. and also i have added this function def _convert(self, space): if type(space) is gym.spaces.discrete.Discrete: return embodied.Space(space.dtype, (1,), 0, space.n) elif type(space) is gym.spaces.multi_discrete.MultiDiscrete: return embodied.Space(space.dtype, (1,), 0, np.prod(space.nvec))

I would like if possible to give me some guidance on how to achieve this???

danijar commented 6 months ago

You probably are trying to load an incompatible old checkpoint? Feel free to reopen.