forked from Kaggle/docker-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade DLVM base-cpu image. http:https://b/167268016 * Build new TF whl * Use new TF whl * Pin tensorforce and add test * fix tf tests
- Loading branch information
Showing
7 changed files
with
44 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import unittest | ||
|
||
from tensorforce import Agent, Environment | ||
|
||
class TestTensorforce(unittest.TestCase): | ||
# based on https://github.com/tensorforce/tensorforce/tree/master#quickstart-example-code. | ||
def test_quickstart(self): | ||
environment = Environment.create( | ||
environment='gym', level='CartPole', max_episode_timesteps=500 | ||
) | ||
|
||
agent = Agent.create( | ||
agent='tensorforce', | ||
environment=environment, # alternatively: states, actions, (max_episode_timesteps) | ||
memory=1000, | ||
update=dict(unit='timesteps', batch_size=32), | ||
optimizer=dict(type='adam', learning_rate=3e-4), | ||
policy=dict(network='auto'), | ||
objective='policy_gradient', | ||
reward_estimation=dict(horizon=1) | ||
) | ||
|
||
# Train for a single episode. | ||
states = environment.reset() | ||
actions = agent.act(states=states) | ||
states, terminal, reward = environment.execute(actions=actions) | ||
|
||
self.assertEqual(4, len(states)) | ||
self.assertFalse(terminal) | ||
self.assertEqual(1, reward) |