def test_sample_with_critic(self, n_actions): model = DiscreteUniform(n_actions=n_actions, critic=DummyCritic()) model_states = model.predict(batch_size=1000) actions = model_states.actions assert len(actions.shape) == 1 assert len(numpy.unique(actions)) <= n_actions assert all(actions >= 0) assert all(actions <= n_actions) assert "critic_score" in model_states.keys() assert (model_states.critic_score == 5).all() states = create_model_states(batch_size=100, model=model) model_states = model.sample(batch_size=states.n, model_states=states) actions = model_states.actions assert len(actions.shape) == 1 assert len(numpy.unique(actions)) <= n_actions assert all(actions >= 0) assert all(actions <= n_actions) assert numpy.allclose(actions, actions.astype(int)) assert "critic_score" in model_states.keys() assert (model_states.critic_score == 5).all()
def test_sample(self, n_actions): model = DiscreteUniform(n_actions=n_actions) model_states = model.predict(batch_size=1000) actions = model_states.actions assert len(actions.shape) == 1 assert len(numpy.unique(actions)) <= n_actions assert all(actions >= 0) assert all(actions <= n_actions) assert "critic_score" in model_states.keys() assert isinstance(model_states.critic_score, numpy.ndarray) assert ( model_states.critic_score == 1).all(), model_states.critic_score states = create_model_states(batch_size=100, model=model) model_states = model.sample(batch_size=states.n, model_states=states) actions = model_states.actions assert len(actions.shape) == 1 assert len(numpy.unique(actions)) <= n_actions assert all(actions >= 0) assert all(actions <= n_actions) assert numpy.allclose(actions, actions.astype(int)) assert "critic_score" in model_states.keys() assert (model_states.critic_score == 1).all()
def test_sample(self, n_actions): model = DiscreteUniform(n_actions=n_actions) model_states = model.predict(batch_size=1000) actions = model_states.actions assert len(actions.shape) == 1 assert len(judo.unique(actions)) <= n_actions assert all(actions >= 0) assert all(actions <= n_actions) assert "critic_score" in model_states.keys() assert dtype.is_tensor(model_states.critic_score) assert ( model_states.critic_score == 1).all(), model_states.critic_score states = create_model_states(batch_size=100, model=model) model_states = model.sample(batch_size=states.n, model_states=states) actions = model_states.actions assert len(actions.shape) == 1 assert len(judo.unique(actions)) <= n_actions assert all(actions >= 0) assert all(actions <= n_actions) assert judo.allclose(actions, judo.astype(actions, dtype.int)) assert "critic_score" in model_states.keys() assert (model_states.critic_score == 1).all()