5bae78c35afe28b014d78b9fe3b78c7f37785091,examples/atari_dqn/convnet.py,ConvNet,_build,#ConvNet#Any#,88
Before Change
def _build(self, convnet_pars):
with tf.variable_scope(None, default_name=self._name):
self._scope_name = tf.get_default_graph().get_name_scope()
self._x = tf.placeholder(tf.float32,
shape=[None,
convnet_pars["height"],
convnet_pars["width"],
convnet_pars["history_length"]],
name="input")
hidden_1 = tf.layers.conv2d(
self._x, 32, 8, 4, activation=tf.nn.relu,
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="hidden_1"
)
hidden_2 = tf.layers.conv2d(
hidden_1, 64, 4, 2, activation=tf.nn.relu,
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="hidden_2"
)
hidden_3 = tf.layers.conv2d(
hidden_2, 64, 3, 1, activation=tf.nn.relu,
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="hidden_3"
)
flatten = tf.reshape(hidden_3, [-1, 7 * 7 * 64], name="flatten")
self._features = tf.layers.dense(
flatten, 512, activation=tf.nn.relu,
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="features"
)
self.q = tf.layers.dense(
self._features, convnet_pars["n_actions"],
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="q"
)
self._target_q = tf.placeholder("float32", [None], name="target_q")
self._action = tf.placeholder("uint8", [None], name="action")
action_one_hot = tf.one_hot(self._action,
convnet_pars["n_actions"],
name="action_one_hot")
self._q_acted = tf.reduce_sum(self.q * action_one_hot,
axis=1,
name="q_acted")
loss = tf.losses.huber_loss(self._target_q, self._q_acted)
tf.summary.scalar("huber_loss", loss)
tf.summary.scalar("average_q", tf.reduce_mean(self.q))
self._merged = tf.summary.merge(
tf.get_collection(tf.GraphKeys.SUMMARIES,
scope=self._scope_name)
)
After Change
def _build(self, convnet_pars):
with tf.variable_scope(None, default_name=self._name):
self._scope_name = tf.get_default_graph().get_name_scope() + "/"
self._x = tf.placeholder(tf.float32,
shape=[None,
convnet_pars["height"],
convnet_pars["width"],
convnet_pars["history_length"]],
name="input")
hidden_1 = tf.layers.conv2d(
self._x, 32, 8, 4, activation=tf.nn.relu,
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="hidden_1"
)
hidden_2 = tf.layers.conv2d(
hidden_1, 64, 4, 2, activation=tf.nn.relu,
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="hidden_2"
)
hidden_3 = tf.layers.conv2d(
hidden_2, 64, 3, 1, activation=tf.nn.relu,
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="hidden_3"
)
flatten = tf.reshape(hidden_3, [-1, 7 * 7 * 64], name="flatten")
self._features = tf.layers.dense(
flatten, 512, activation=tf.nn.relu,
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="features"
)
self.q = tf.layers.dense(
self._features, convnet_pars["n_actions"],
kernel_initializer=tf.glorot_uniform_initializer(),
bias_initializer=tf.glorot_uniform_initializer(),
name="q"
)
self._target_q = tf.placeholder("float32", [None], name="target_q")
self._action = tf.placeholder("uint8", [None], name="action")
action_one_hot = tf.one_hot(self._action,
convnet_pars["n_actions"],
name="action_one_hot")
self._q_acted = tf.reduce_sum(self.q * action_one_hot,
axis=1,
name="q_acted")
loss = tf.losses.huber_loss(self._target_q, self._q_acted)
tf.summary.scalar("huber_loss", loss)
tf.summary.scalar("average_q", tf.reduce_mean(self.q))
self._merged = tf.summary.merge(
tf.get_collection(tf.GraphKeys.SUMMARIES,
scope=self._scope_name)
)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances
Project Name: AIRLab-POLIMI/mushroom
Commit Name: 5bae78c35afe28b014d78b9fe3b78c7f37785091
Time: 2017-10-20
Author: carloderamo@gmail.com
File Name: examples/atari_dqn/convnet.py
Class Name: ConvNet
Method Name: _build
Project Name: AIRLab-POLIMI/mushroom
Commit Name: d026cbaf0bbd847c7cf4dfb652361f6d1db562b7
Time: 2017-09-29
Author: carloderamo@gmail.com
File Name: examples/atari_dqn/convnet.py
Class Name: ConvNet
Method Name: _build
Project Name: AIRLab-POLIMI/mushroom
Commit Name: f067dac7cac8093b726d0ffb56bde6000c1f7bf1
Time: 2017-09-20
Author: carloderamo@gmail.com
File Name: examples/atari_dqn/convnet.py
Class Name: ConvNet
Method Name: _build