(self, batch, global_step, num_rec_out=1, save_imgs=True)
Runs a training step using the global loss on each of the scale networks.

        @param batch: An array of shape
                      [batch_size x self.height x self.width x (3 * (c.HIST_LEN+ num_rec_out))].
                      A batch of the input and output frames, concatenated along the channel axis
                      (index 3).
        @param global_step: The global step.
        @param num_rec_out: The number of outputs to predict. Outputs > 1 are computed recursively,
                            using previously-generated frames as input. Default = 1.
        @param save_imgs: Whether or not to save the input/output images to file. Default = True.

        @return: A tuple of (psnr error, sharpdiff error) for the batch.
Runs a training step using the global loss on each of the scale networks.
Runs a training step using the global loss on each of the scale networks .
def test_batch(self, batch, global_step, num_rec_out=1, save_imgs=True):
        """
        Runs a training step using the global loss on each of the scale networks.

        @param batch: An array of shape
                      [batch_size x self.height x self.width x (3 * (c.HIST_LEN+ num_rec_out))].
                      A batch of the input and output frames, concatenated along the channel axis
                      (index 3).
        @param global_step: The global step.
        @param num_rec_out: The number of outputs to predict. Outputs > 1 are computed recursively,
                            using previously-generated frames as input. Default = 1.
        @param save_imgs: Whether or not to save the input/output images to file. Default = True.

        @return: A tuple of (psnr error, sharpdiff error) for the batch.
        """
        if num_rec_out < 1:
            raise ValueError('num_rec_out must be >= 1')

        print '-' * 30
        print 'Testing:'

        ##
        # Split into inputs and outputs
        ##

        input_frames = batch[:, :, :, :3 * c.HIST_LEN]
        gt_frames = batch[:, :, :, 3 * c.HIST_LEN:]

        ##
        # Generate num_rec_out recursive predictions
        ##

        working_input_frames = deepcopy(input_frames)  # input frames that will shift w/ recursion
        rec_preds = []
        rec_summaries = []
        for rec_num in xrange(num_rec_out):
            working_gt_frames = gt_frames[:, :, :, 3 * rec_num:3 * (rec_num + 1)]

            feed_dict = {self.input_frames_test: working_input_frames,
                         self.gt_frames_test: working_gt_frames}
            preds, psnr, sharpdiff, summaries = self.sess.run([self.scale_preds_test[-1],
                                                               self.psnr_error_test,
                                                               self.sharpdiff_error_test,
                                                               self.summaries_test],
                                                              feed_dict=feed_dict)

            # remove first input and add new pred as last input
            working_input_frames = np.concatenate(
                [working_input_frames[:, :, :, 3:], preds], axis=3)

            # add predictions and summaries
            rec_preds.append(preds)
            rec_summaries.append(summaries)

            print 'Recursion ', rec_num
            print 'PSNR Error     : ', psnr
            print 'Sharpdiff Error: ', sharpdiff

        # write summaries
        # TODO: Think of a good way to write rec output summaries - rn, just using first output.
        self.summary_writer.add_summary(rec_summaries[0], global_step)

        ##
        # Save images
        ##

        if save_imgs:
            for pred_num in xrange(len(input_frames)):
                pred_dir = c.get_dir(os.path.join(
                    c.IMG_SAVE_DIR, 'Tests/Step_' + str(global_step), str(pred_num)))

                # save input images
                for frame_num in xrange(c.HIST_LEN):
                    img = input_frames[pred_num, :, :, (frame_num * 3):((frame_num + 1) * 3)]
                    imsave(os.path.join(pred_dir, 'input_' + str(frame_num) + '.png'), img)

                # save recursive outputs
                for rec_num in xrange(num_rec_out):
                    gen_img = rec_preds[rec_num][pred_num]
                    gt_img = gt_frames[pred_num, :, :, 3 * rec_num:3 * (rec_num + 1)]
                    imsave(os.path.join(pred_dir, 'gen_' + str(rec_num) + '.png'), gen_img)
                    imsave(os.path.join(pred_dir, 'gt_' + str(rec_num) + '.png'), gt_img)

        print '-' * 30
def test_batch ( self , batch , global_step , num_rec_out = 1 , save_imgs = True ) : if num_rec_out < 1 : raise ValueError ( 'num_rec_out must be >= 1' ) print '-' * 30 print 'Testing:' ## # Split into inputs and outputs ## input_frames = batch [ : , : , : , : 3 * c . HIST_LEN ] gt_frames = batch [ : , : , : , 3 * c . HIST_LEN : ] ## # Generate num_rec_out recursive predictions ## working_input_frames = deepcopy ( input_frames ) # input frames that will shift w/ recursion rec_preds = [ ] rec_summaries = [ ] for rec_num in xrange ( num_rec_out ) : working_gt_frames = gt_frames [ : , : , : , 3 * rec_num : 3 * ( rec_num + 1 ) ] feed_dict = { self . input_frames_test : working_input_frames , self . gt_frames_test : working_gt_frames } preds , psnr , sharpdiff , summaries = self . sess . run ( [ self . scale_preds_test [ - 1 ] , self . psnr_error_test , self . sharpdiff_error_test , self . summaries_test ] , feed_dict = feed_dict ) # remove first input and add new pred as last input working_input_frames = np . concatenate ( [ working_input_frames [ : , : , : , 3 : ] , preds ] , axis = 3 ) # add predictions and summaries rec_preds . append ( preds ) rec_summaries . append ( summaries ) print 'Recursion ' , rec_num print 'PSNR Error     : ' , psnr print 'Sharpdiff Error: ' , sharpdiff # write summaries # TODO: Think of a good way to write rec output summaries - rn, just using first output. self . summary_writer . add_summary ( rec_summaries [ 0 ] , global_step ) ## # Save images ## if save_imgs : for pred_num in xrange ( len ( input_frames ) ) : pred_dir = c . get_dir ( os . path . join ( c . IMG_SAVE_DIR , 'Tests/Step_' + str ( global_step ) , str ( pred_num ) ) ) # save input images for frame_num in xrange ( c . HIST_LEN ) : img = input_frames [ pred_num , : , : , ( frame_num * 3 ) : ( ( frame_num + 1 ) * 3 ) ] imsave ( os . path . join ( pred_dir , 'input_' + str ( frame_num ) + '.png' ) , img ) # save recursive outputs for rec_num in xrange ( num_rec_out ) : gen_img = rec_preds [ rec_num ] [ pred_num ] gt_img = gt_frames [ pred_num , : , : , 3 * rec_num : 3 * ( rec_num + 1 ) ] imsave ( os . path . join ( pred_dir , 'gen_' + str ( rec_num ) + '.png' ) , gen_img ) imsave ( os . path . join ( pred_dir , 'gt_' + str ( rec_num ) + '.png' ) , gt_img ) print '-' * 30