Exemple #1
0
def test_load_and_save():
    env = gym.make('CartPole-v0')
    M = Model(env, build_graph, build_update_feed_dict)
    M.update([0, 0, 0, 0], 2)
    weights = M.G._session.run(M['vars'])
    M.save('test_load_and_save_model')
    M.update([0, 0, 0, 0], 2)
    del M
    M = Model.load(path='test_load_and_save_model')
    weights2 = M.G._session.run(M['vars'])
    M.build_update_feed([0, 1, 0, 1], 2)
    M.update([0, 0, 0, 0], 2)
    shutil.rmtree('test_load_and_save_model')
    assert np.allclose(weights, weights2)
Exemple #2
0
def test_update_model():
    env = gym.make('CartPole-v0')
    M = Model(env, build_graph, build_update_feed_dict)
    loss = M.update([0, 0, 0, 0], 2)
    assert loss[0] == [4.]