forked from kzl/decision-transformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsetcreation.py
32 lines (26 loc) · 877 Bytes
/
dsetcreation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import minari
import gymnasium as gym
from minari import DataCollector
env = gym.make('FrozenLake-v1')
env = DataCollector(env)
for _ in range(5):
env.reset()
done = False
while not done:
action = env.action_space.sample() # <- use your policy here
obs, rew, terminated, truncated, info = env.step(action)
done = terminated or truncated
dataset = env.create_dataset("frozenlake-test-v0-2")
#dataset = minari.load_dataset("frozenlake-test-v0")
#print(dataset)
print(env.action_space.n)
for episode_data in dataset.iterate_episodes():
#print(episode_data)
observations = episode_data.observations
actions = episode_data.actions
print(actions)
rewards = episode_data.rewards
#print(rewards)
terminations = episode_data.terminations
truncations = episode_data.truncations
infos = episode_data.infos