tyrion

mushroom tiles

Feb 6th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 KB | None | 0 0
  1. In [142]: if 1:
  2.      ...:     import preprocessing
  3.      ...:     P = 5
  4.      ...:     V = 7
  5.      ...:     pos = np.linspace(-1, 1, P)
  6.      ...:     vel = np.linspace(-3, 3, V)
  7.      ...:     actions = np.array([[0],[1]])
  8.      ...:     dataset = []
  9.      ...:     mdp = CarOnHill()
  10.      ...:     mdp.reset()
  11.      ...:     for p in pos:
  12.      ...:         for v in vel:
  13.      ...:             for a in actions:
  14.      ...:                 mdp._state = s = np.array([p, v])
  15.      ...:                 n, r, ab, _ = mdp.step(a)
  16.      ...:                 dataset.append((s, a, r, n, ab, ab))
  17.      ...:     s = parse_dataset(dataset)[0]    
  18.      ...:    
  19.      ...:     tilings = Tiles.generate(1, [P, V], mdp.info.observation_space.low, mdp.info.observation_space.high)
  20.      ...:     features = Features(tilings=tilings)
  21.      ...:     simple_tiles = preprocessing.SimpleTiles2D(pos, vel)
  22.      ...:     one_hot_prep = preprocessing.OneHot(simple_tiles.depth)
  23.      ...:    
  24.      ...:     f1 = features(s)
  25.      ...:     n2 = simple_tiles(s)
  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.      ...:    
  30. ---------------------------------------------------------------------------
  31. AssertionError                            Traceback (most recent call last)
  32. <ipython-input-142-948d6cb45b7c> in <module>()
  33.      26     f2 = one_hot_prep(n2)
  34.      27     assert np.all(f2.sum(0) == 2.)
  35. ---> 28     assert np.all(f1.sum(0) == 2.), "mushroom error"
  36.      29
  37.  
  38. AssertionError: mushroom error
  39.  
  40. In [144]: f1.sum(0)
  41. Out[144]:
  42. 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,
  43.        +2.0000, +2.0000, +0.0000, +2.0000, +2.0000, +2.0000, +2.0000, +0.0000, +2.0000, +2.0000, +2.0000, +2.0000,
  44.        +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