def loadGame(param_dir): gs = dict() with open(param_dir, 'rb') as f: shimon_hero_params = pickle.load(f) for paramater in shimon_hero_params: gs[paramater] = shimon_hero_params[paramater] game = sh.Game(gs) return game
img_channels = 4 # Stack 4 frames to infer movement # Initialize instance of Shimon Hero game gs = dict() #gs['NUMBER_OF_ARMS'] = 2 gs['NOTE_HEIGHT'] = 20 gs['NOTE_WIDTH'] = 5 gs['ARM_WIDTH'] = 5 gs['ARM_SPEED'] = 2 gs['TOTAL_NUM_NOTES'] = 12 gs['POINT_THRESHOLD'] = -1. gs['PENALTY_MISSING_NOTE'] = -0.2 gs['PROB_NOTE_SPAWNED'] = 0.006 game = sh.Game(gs) # Instantiate Shimon Hero game timestr = time.strftime("%m-%d_%H-%M-%S") # save the current time to name the model shimon_hero_param = game.get_settings() if SAVE_MODEL: name = "model_" + timestr + "_param.p" dir_path = "./saved_models/" + name with open(dir_path, 'wb') as f: pickle.dump(shimon_hero_param, f, pickle.HIGHEST_PROTOCOL) # Note that in order for saving to pick;e to work, I had to comment out sock.socket object from Zach's Shimon Hero # In the newest version of Keras (February 2017), you need to pass a kwarg called "dim_ordering" when initializing weights def my_init(shape, name=None, dim_ordering=None): return initializations.normal(shape, scale=0.01, name=name) def buildmodel():
action_dict = {0: -1, 1: 0, 2: 1} # Shimon hero will interpret [-1] as one arm left, [1] as one arm right. Or [-1 -1] as two arm left and left. # So if QNN gives [1 0 0], then in img_rows , img_cols = 80, 80 # All images are downsampled to 80 x 80 img_channels = 4 # Stack 4 frames to infer movement # Initialize instance of Shimon Hero game gs = dict() #gs['NUMBER_OF_ARMS'] = 4 gs['NOTE_HEIGHT'] = 20 gs['NOTE_WIDTH'] = 10 gs['TOTAL_NUM_NOTES'] = 12 game = sh.Game(gs) timestr = time.strftime("%m-%d_%H-%M-%S") # save the current time to name the model # In the newest version of Keras (February 2017), you need to pass a kwarg called "dim_ordering" when initializing weights def my_init(shape, name=None, dim_ordering=None): return initializations.normal(shape, scale=0.01, name=name) def buildmodel(): # Build the model using the same specifications as the DeepMind paper # Keras is a good library for protrotyping a quick model and will later # be modified/used in conjunction with pure tensorflow code # TODO: Need to figure out how to run on GPU print("Building CNN Model") model = Sequential()
NUM_ACTIONS = 4 # number of valid actions GAMMA = 0.99 # decay rate of past observations OBSERVATION = 3200. # timesteps to observe before training EXPLORE = 3000000. # frames over which to anneal epsilon FINAL_EPSILON = 0.0001 # final value of epsilon INITIAL_EPSILON = 0.1 # starting value of epsilon REPLAY_MEMORY = 50000 # number of previous transitions to remember BATCH = 32 # size of minibatch FRAME_PER_ACTION = 1 # This controls how many frames to wait before deciding on an action. If F_P_A = 1, then Shimon # chooses a new action every tick, which causes erratic movements with no exploration middle spaces img_rows, img_cols = 80, 80 # All images are downsampled to 80 x 80 img_channels = 4 # Stack 4 frames to infer movement # Initialize instance of Shimon Hero game game = sh.Game(human_playing=False) timestr = time.strftime( "%m-%d_%H-%M-%S") # save the current time to name the model # In the newest version of Keras (February 2017), you need to pass a kwarg called "dim_ordering" when initializing weights def my_init(shape, name=None, dim_ordering=None): return initializations.normal(shape, scale=0.01, name=name) def buildmodel(): # Build the model using the same specifications as the DeepMind paper # Keras is a good library for protrotyping a quick model and will later # be modified/used in conjunction with pure tensorflow code # TODO: Need to figure out how to run on GPU
NUM_ACTIONS = 4 # number of valid actions GAMMA = 0.99 # decay rate of past observations OBSERVATION = 3200. # timesteps to observe before training EXPLORE = 3000000. # frames over which to anneal epsilon FINAL_EPSILON = 0.0001 # final value of epsilon INITIAL_EPSILON = 0.1 # starting value of epsilon REPLAY_MEMORY = 50000 # number of previous transitions to remember BATCH = 32 # size of minibatch FRAME_PER_ACTION = 1 # This controls how many frames to wait before deciding on an action. If F_P_A = 1, then Shimon # chooses a new action every tick, which causes erratic movements with no exploration middle spaces img_rows, img_cols = 80, 80 # All images are downsampled to 80 x 80 img_channels = 4 # Stack 4 frames to infer movement # Initialize instance of Shimon Hero game game = sh.Game() # In the newest version of Keras (February 2017), you need to pass a kwarg called "dim_ordering" when initializing weights def my_init(shape, name=None, dim_ordering=None): return initializations.normal(shape, scale=0.01, name=name) def buildmodel(): # Build the model using the same specifications as the DeepMind paper # Keras is a good library for protrotyping a quick model and will later # be modified/used in conjunction with pure tensorflow code # TODO: Need to figure out how to run on GPU print("Building CNN Model") model = Sequential()