parameters: (self, new_bs)
return_statement: return new_model_file
docstring: return new model with real data input
docstring_summary: return new model with real data input
docstring_tokens: return new model with real data input
function: def _gen_new_real_model(self, new_bs):
          '''return new model with real data input'''
          new_model_file = self._gen_new_model_file_name(new_bs)
          batch_size_pattern = re.compile("^\s+batch_size:.*")
          bn_stats_batch_size_pattern = re.compile(".*bn_stats_batch_size:.*")
          # we only care about train phase batch size 
          batch_size_cnt = 1
          with open(self.model_file, 'r') as src_f, open(new_model_file, 'w') as dst_f:
              cnt = 0
              for line in src_f.readlines():
                  if re.match(batch_size_pattern, line) and cnt < batch_size_cnt:
                      line = re.sub('[0-9]+', new_bs, line, count = 1)
                      cnt += 1
                  #consider bn_stats_batch_size field
                  if re.match(bn_stats_batch_size_pattern, line):
                      line = re.sub('[0-9]+', new_bs, line, count = 1)
                  dst_f.write(line)
          if cnt < batch_size_cnt:
              logging.exception("Error: can't find batch size pattern within the model file {}.".format(self.model_file))
          return new_model_file
function_tokens: def _gen_new_real_model ( self , new_bs ) : new_model_file = self . _gen_new_model_file_name ( new_bs ) batch_size_pattern = re . compile ( "^\s+batch_size:.*" ) bn_stats_batch_size_pattern = re . compile ( ".*bn_stats_batch_size:.*" ) # we only care about train phase batch size  batch_size_cnt = 1 with open ( self . model_file , 'r' ) as src_f , open ( new_model_file , 'w' ) as dst_f : cnt = 0 for line in src_f . readlines ( ) : if re . match ( batch_size_pattern , line ) and cnt < batch_size_cnt : line = re . sub ( '[0-9]+' , new_bs , line , count = 1 ) cnt += 1 #consider bn_stats_batch_size field if re . match ( bn_stats_batch_size_pattern , line ) : line = re . sub ( '[0-9]+' , new_bs , line , count = 1 ) dst_f . write ( line ) if cnt < batch_size_cnt : logging . exception ( "Error: can't find batch size pattern within the model file {}." . format ( self . model_file ) ) return new_model_file