Esempio n. 1
0
    def train(self):
        """ Run training function. Save model upon completion """
        self.print_log('Training for %d epochs' % self.flags['NUM_EPOCHS'])

        tf_inputs = (self.x['TRAIN'], self.im_dims['TRAIN'],
                     self.gt_boxes['TRAIN'])

        for self.epoch in trange(1,
                                 self.flags['NUM_EPOCHS'] + 1,
                                 desc='epochs'):
            train_order = randomize_training_order(len(self.names['TRAIN']))

            for i in tqdm(train_order):
                feed_dict = create_feed_dict(self.flags['DATA_DIRECTORY'],
                                             self.names['TRAIN'], tf_inputs, i)

                # Run a training iteration
                if self.step % cfg.DISPLAY_RATE == 0:
                    # Record training metrics every DISPLAY_RATE interval
                    summary = self._record_train_metrics(feed_dict)
                    self._record_training_step(summary)
                else:
                    summary, _ = self.sess.run([self.merged, self.optimizer],
                                               feed_dict=feed_dict)
                    self._record_training_step(summary)

                    # Epoch finishe; save model
            if self.epoch % cfg.CHECKPOINT_RATE == 0:
                self._save_model(section=self.epoch)
            # Perform validation
            if self.epoch % cfg.VALID_RATE == 0:
                self.evaluate(test=False)
Esempio n. 2
0
    def train(self):
        """ Run training function. Save model upon completion """
        self.print_log('Training for %d epochs' % self.flags['num_epochs'])

        tf_inputs = (self.x['TRAIN'], self.im_dims['TRAIN'],
                     self.gt_boxes['TRAIN'])

        self.step += 1
        for self.epoch in trange(1,
                                 self.flags['num_epochs'] + 1,
                                 desc='epochs'):
            train_order = randomize_training_order(len(self.names['TRAIN']))

            for i in tqdm(train_order):
                feed_dict = create_feed_dict(flags['data_directory'],
                                             self.names['TRAIN'], tf_inputs, i)

                # Run a training iteration
                if self.step % (self.flags['display_step']) == 0:
                    # Record training metrics every display_step interval
                    summary = self._record_train_metrics(feed_dict)
                    self._record_training_step(summary)
                else:
                    summary = self._run_train_iter(feed_dict)
                    self._record_training_step(summary)

            ## Epoch finished
            # Save model
            if self.epoch % cfg.CHECKPOINT_RATE == 0:
                self._save_model(section=self.epoch)
            # Perform validation
            if self.epoch % cfg.VALID_RATE == 0:
                self.evaluate(test=False)
Esempio n. 3
0
 def train(self):
     """ Run training function. Save model upon completion """
     self.print_log('Training for %d epochs' % self.flags['num_epochs'])
     
     tf_inputs = (self.x['TRAIN'], self.im_dims['TRAIN'], self.gt_boxes['TRAIN'])
     
     self.step += 1
     for self.epoch in trange(1, self.flags['num_epochs']+1, desc='epochs'):
         train_order = randomize_training_order(len(self.names['TRAIN']))
         
         for i in tqdm(train_order):
             feed_dict = create_feed_dict(flags['data_directory'], self.names['TRAIN'], tf_inputs, i)
             
             # Run a training iteration
             if self.step % (self.flags['display_step']) == 0:
                 # Record training metrics every display_step interval
                 summary = self._record_train_metrics(feed_dict)
                 self._record_training_step(summary)
             else: 
                 summary = self._run_train_iter(feed_dict)
                 self._record_training_step(summary)             
         
         ## Epoch finished
         # Save model 
         if self.epoch % cfg.CHECKPOINT_RATE == 0: 
             self._save_model(section=self.epoch)
         # Perform validation
         if self.epoch % cfg.VALID_RATE == 0: 
             self.evaluate(test=False)