Skip to content

Commit

Permalink
Python3.5対応
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsukara committed Aug 2, 2016
1 parent 9f97b2b commit 5cbce40
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions a3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ def log_uniform(lo, hi, rate):
checkpoint = tf.train.get_checkpoint_state(CHECKPOINT_DIR)
if checkpoint and checkpoint.model_checkpoint_path:
saver.restore(sess, checkpoint.model_checkpoint_path)
print "checkpoint loaded:", checkpoint.model_checkpoint_path
print("checkpoint loaded:", checkpoint.model_checkpoint_path)
tokens = checkpoint.model_checkpoint_path.split("-")
# set global step
global_t = int(tokens[1])
print ">>> global step set: ", global_t
print(">>> global step set: ", global_t)
else:
print "Could not find old checkpoint"
print("Could not find old checkpoint")


def train_function(parallel_index):
Expand Down
4 changes: 2 additions & 2 deletions a3c_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def choose_action(pi_values):
checkpoint = tf.train.get_checkpoint_state(CHECKPOINT_DIR)
if checkpoint and checkpoint.model_checkpoint_path:
saver.restore(sess, checkpoint.model_checkpoint_path)
print "checkpoint loaded:", checkpoint.model_checkpoint_path
print("checkpoint loaded:", checkpoint.model_checkpoint_path)
else:
print "Could not find old checkpoint"
print("Could not find old checkpoint")

game_state = GameState(0, display=True, no_op_max=0)

Expand Down
8 changes: 4 additions & 4 deletions a3c_training_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def process(self, sess, global_t, summary_writer, summary_op, score_input):
values.append(value_)

if (self.thread_index == 0) and (self.local_t % 100) == 0:
print "pi=", pi_
print " V=", value_
print("pi=", pi_)
print(" V=", value_)

# process game
self.game_state.process(action)
Expand All @@ -136,7 +136,7 @@ def process(self, sess, global_t, summary_writer, summary_op, score_input):

if terminal:
terminal_end = True
print "score=", self.episode_reward
print("score=", self.episode_reward)

self._record_score(sess, summary_writer, summary_op, score_input,
self.episode_reward, global_t)
Expand Down Expand Up @@ -201,7 +201,7 @@ def process(self, sess, global_t, summary_writer, summary_op, score_input):
feed_dict = { self.learning_rate_input: cur_learning_rate } )

if (self.thread_index == 0) and (self.local_t % 100) == 0:
print "TIMESTEP", self.local_t
print("TIMESTEP", self.local_t)

# return advanced local step size
diff_local_t = self.local_t - start_local_t
Expand Down
4 changes: 2 additions & 2 deletions a3c_visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
checkpoint = tf.train.get_checkpoint_state(CHECKPOINT_DIR)
if checkpoint and checkpoint.model_checkpoint_path:
saver.restore(sess, checkpoint.model_checkpoint_path)
print "checkpoint loaded:", checkpoint.model_checkpoint_path
print("checkpoint loaded:", checkpoint.model_checkpoint_path)
else:
print "Could not find old checkpoint"
print("Could not find old checkpoint")

W_conv1 = sess.run(global_network.W_conv1)

Expand Down
2 changes: 1 addition & 1 deletion accum_trainer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def testBatchAccum(self):
#cost = tf.square(mul)
cost = tf.reduce_sum( tf.square(mul) )

print cost.get_shape()
print(cost.get_shape())

trainer.prepare_minimize(cost, [var0])

Expand Down
10 changes: 5 additions & 5 deletions game_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
class GameState(object):
def __init__(self, rand_seed, display=False, no_op_max=7):
self.ale = ALEInterface()
self.ale.setInt('random_seed', rand_seed)
self.ale.setInt(b'random_seed', rand_seed)
self._no_op_max = no_op_max

if display:
self._setup_display()

self.ale.loadROM(ROM)
self.ale.loadROM(ROM.encode('ascii'))

# collect minimal action set
self.real_actions = self.ale.getMinimalActionSet()
Expand Down Expand Up @@ -51,10 +51,10 @@ def _setup_display(self):
if sys.platform == 'darwin':
import pygame
pygame.init()
self.ale.setBool('sound', False)
self.ale.setBool(b'sound', False)
elif sys.platform.startswith('linux'):
self.ale.setBool('sound', True)
self.ale.setBool('display_screen', True)
self.ale.setBool(b'sound', True)
self.ale.setBool(b'display_screen', True)

def reset(self):
self.ale.reset_game()
Expand Down

0 comments on commit 5cbce40

Please sign in to comment.