Skip to content

Change imports in tf-agents example to support updated version #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tf-agents-example/gridworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from tf_agents.environments import tf_environment
from tf_agents.environments import tf_py_environment
from tf_agents.environments import utils
from tf_agents.specs import array_spec
from tf_agents.environments import time_step as ts
from tf_agents.environments import wrappers
from tf_agents.specs import array_spec
from tf_agents.trajectories import time_step as ts

tf.compat.v1.enable_v2_behavior()

Expand Down
9 changes: 5 additions & 4 deletions tf-agents-example/simulate.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import tensorflow as tf

from tf_agents.agents.dqn import dqn_agent
from tf_agents.agents.dqn import q_network
from tf_agents.networks import q_network
from tf_agents.drivers import dynamic_step_driver
from tf_agents.environments import tf_py_environment
from tf_agents.environments import trajectory
from tf_agents.environments import wrappers
from tf_agents.metrics import metric_utils
from tf_agents.eval import metric_utils
from tf_agents.metrics import tf_metrics
from tf_agents.policies import random_tf_policy
from tf_agents.replay_buffers import tf_uniform_replay_buffer
from tf_agents.trajectories import trajectory
from tf_agents.utils import common
from tf_agents.metrics import py_metrics
from tf_agents.metrics import tf_metrics
from tf_agents.drivers import py_driver
from tf_agents.drivers import dynamic_episode_driver
from tf_agents.utils import common

from gridworld import GridWorldEnv
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -71,7 +72,7 @@ def compute_avg_return(environment, policy, num_episodes=10):
train_env.action_spec(),
q_network=q_net,
optimizer=optimizer,
td_errors_loss_fn = dqn_agent.element_wise_squared_loss,
td_errors_loss_fn = common.element_wise_squared_loss,
train_step_counter=train_step_counter)

tf_agent.initialize()
Expand Down