def __init__(self): #Setting the training parameters self.batch_size = 4 #How many experience traces to use for each training step. self.trace_length = 8 #How long each experience trace will be when training self.update_freq = 5 #How often to perform a training step. self.y = .99 #Discount factor on the target Q-values self.startE = 1 #Starting chance of random action self.endE = 0.1 #Final chance of random action self.anneling_steps = 10000 #How many steps of training to reduce startE to endE. self.num_episodes = 10000 #How many episodes of game environment to train network with. self.pre_train_steps = 10000 #How many steps of random actions before training begins. self.load_model = True #Whether to load a saved model. self.path = "./drqn" #The path to save our model to. self.h_size = 512 #The size of the final convolutional layer before splitting it into Advantage and Value streams. self.max_epLength = 300 #The max allowed length of our episode. self.time_per_step = 1 #Length of each step used in gif creation self.summaryLength = 100 #Number of epidoes to periodically save for analysis self.tau = 0.001 # for Tracking self.cap = None self.col = -1 self.width = -1 self.row = -1 self.height = -1 self.frame = None self.frame2 = None self.inputmode = False self.rectangle = False self.trackWindow = None self.roi_hist = None self.roi = None self.caffe_model_path = './MobileNetSSD_deploy.caffemodel' self.prorotxt_path = './MobileNetSSD_deploy.prototxt.txt' self.net = None self.obstacle_points = [] self.target_point = None self.obstacle_box_color = (0, 0, 255) self.tracker_types = [ 'BOOSTING', 'MIL', 'KCF', 'TLD', 'MEDIANFLOW', 'GOTURN' ] self.tracker_type = self.tracker_types[2] if self.tracker_type == 'BOOSTING': self.tracker = cv2.TrackerBoosting_create() if self.tracker_type == 'MIL': self.tracker = cv2.TrackerMIL_create() if self.tracker_type == 'KCF': self.tracker = cv2.TrackerKCF_create() if self.tracker_type == 'TLD': self.tracker = cv2.TrackerTLD_create() else: self.tracker = cv2.TrackerMedianFlow_create() self.game = sim(200, True)
def __init__(self): #Setting the training parameters self.batch_size = 4 #How many experience traces to use for each training step. self.trace_length = 8 #How long each experience trace will be when training self.update_freq = 5 #How often to perform a training step. self.y = .99 #Discount factor on the target Q-values self.startE = 1 #Starting chance of random action self.endE = 0.1 #Final chance of random action self.anneling_steps = 10000 #How many steps of training to reduce startE to endE. self.num_episodes = 10000 #How many episodes of game environment to train network with. self.pre_train_steps = 10000 #How many steps of random actions before training begins. self.load_model = False #Whether to load a saved model. self.path = "./drqn" #The path to save our model to. self.h_size = 512 #The size of the final convolutional layer before splitting it into Advantage and Value streams. self.max_epLength = 300 #The max allowed length of our episode. self.time_per_step = 1 #Length of each step used in gif creation self.summaryLength = 100 #Number of epidoes to periodically save for analysis self.tau = 0.001 self.game = sim(200, True)
def __init__(self, flag): self.batch_size = 64 #How many experiences to use for each training step. self.update_freq = 4 #How often to perform a training step. self.y = .99 #Discount factor on the target Q-values self.startE = 1 #Starting chance of random action self.endE = 0.1 #Final chance of random action self.annealing_steps = 10000. #How many steps of training to reduce startE to endE. self.num_episodes = 10000 #How many episodes of game environment to train network with. self.pre_train_steps = 10000 #How many steps of random actions before training begins. self.max_epLength = 300 #The max allowed length of our episode. self.load_model = False #Whether to load a saved model. self.path = "./dqn" #The path to save our model to. self.h_size = 512 #The size of the final convolutional layer before splitting it into Advantage and Value streams. self.tau = 0.001 #Rate to update target network toward primary network self.action_num = 5 tf.reset_default_graph() self.mainQN = DQN(self.h_size, self.action_num) self.targetQN = DQN(self.h_size, self.action_num) self.init = tf.global_variables_initializer() self.saver = tf.train.Saver() self.trainables = tf.trainable_variables() self.targetOps = self.updateTargetGraph(self.trainables, self.tau) self.myBuffer = experience_buffer() # Set the rate of random action decrease. self.e = self.startE self.stepDrop = (self.startE - self.endE) / self.annealing_steps # create lists to contain total rewards and steps per episode self.jList = [] self.rList = [] self.total_steps = 0 self.game = sim(200, True) self.is_Train = flag # for Tracking self.cap = None self.col = -1 self.width = -1 self.row = -1 self.height = -1 self.frame = None self.frame2 = None self.inputmode = False self.rectangle = False self.trackWindow = None self.roi_hist = None self.roi = None self.caffe_model_path = './MobileNetSSD_deploy.caffemodel' self.prorotxt_path = './MobileNetSSD_deploy.prototxt.txt' self.net = None self.obstacle_points = [] self.target_point = None self.obstacle_box_color = (0, 0, 255) self.tracker_types = [ 'BOOSTING', 'MIL', 'KCF', 'TLD', 'MEDIANFLOW', 'GOTURN' ] self.tracker_type = self.tracker_types[2] if self.tracker_type == 'BOOSTING': self.tracker = cv2.TrackerBoosting_create() if self.tracker_type == 'MIL': self.tracker = cv2.TrackerMIL_create() if self.tracker_type == 'KCF': self.tracker = cv2.TrackerKCF_create() if self.tracker_type == 'TLD': self.tracker = cv2.TrackerTLD_create() else: self.tracker = cv2.TrackerMedianFlow_create()