Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [142]: if 1:
- ...: import preprocessing
- ...: P = 5
- ...: V = 7
- ...: pos = np.linspace(-1, 1, P)
- ...: vel = np.linspace(-3, 3, V)
- ...: actions = np.array([[0],[1]])
- ...: dataset = []
- ...: mdp = CarOnHill()
- ...: mdp.reset()
- ...: for p in pos:
- ...: for v in vel:
- ...: for a in actions:
- ...: mdp._state = s = np.array([p, v])
- ...: n, r, ab, _ = mdp.step(a)
- ...: dataset.append((s, a, r, n, ab, ab))
- ...: s = parse_dataset(dataset)[0]
- ...:
- ...: tilings = Tiles.generate(1, [P, V], mdp.info.observation_space.low, mdp.info.observation_space.high)
- ...: features = Features(tilings=tilings)
- ...: simple_tiles = preprocessing.SimpleTiles2D(pos, vel)
- ...: one_hot_prep = preprocessing.OneHot(simple_tiles.depth)
- ...:
- ...: f1 = features(s)
- ...: n2 = simple_tiles(s)
- ...: f2 = one_hot_prep(n2)
- ...: assert np.all(f2.sum(0) == 2.)
- ...: assert np.all(f1.sum(0) == 2.), "mushroom error"
- ...:
- ---------------------------------------------------------------------------
- AssertionError Traceback (most recent call last)
- <ipython-input-142-948d6cb45b7c> in <module>()
- 26 f2 = one_hot_prep(n2)
- 27 assert np.all(f2.sum(0) == 2.)
- ---> 28 assert np.all(f1.sum(0) == 2.), "mushroom error"
- 29
- AssertionError: mushroom error
- In [144]: f1.sum(0)
- Out[144]:
- array([+2.0000, +2.0000, +2.0000, +2.0000, +0.0000, +2.0000, +2.0000, +2.0000, +2.0000, +0.0000, +2.0000, +2.0000,
- +2.0000, +2.0000, +0.0000, +2.0000, +2.0000, +2.0000, +2.0000, +0.0000, +2.0000, +2.0000, +2.0000, +2.0000,
- +0.0000, +2.0000, +2.0000, +2.0000, +2.0000, +0.0000, +0.0000, +0.0000, +0.0000, +0.0000, +0.0000])
Advertisement
Add Comment
Please, Sign In to add comment