(self, data)
return normalizer
Computes and saves normalizer.
Computes and saves normalizer.
Computes and saves normalizer .
def save(self, data):
    """Computes and saves normalizer."""
    if self.exists():
      logging.info('Skip save() as %s already exists', self._done_path)
      return
    data_np = self._run_data(data)
    normalizer = self.compute(data_np)
    logging.info('Save normalizer to %s', self._path)
    bytes_io = io.BytesIO()
    np.savez(bytes_io, normalizer=normalizer)
    if not tf.gfile.Exists(self._work_dir):
      tf.gfile.MakeDirs(self._work_dir)
    with tf.gfile.Open(self._path, 'wb') as f:
      f.write(bytes_io.getvalue())
    with tf.gfile.Open(self._done_path, 'w') as f:
      f.write('')
    return normalizer
def save ( self , data ) : if self . exists ( ) : logging . info ( 'Skip save() as %s already exists' , self . _done_path ) return data_np = self . _run_data ( data ) normalizer = self . compute ( data_np ) logging . info ( 'Save normalizer to %s' , self . _path ) bytes_io = io . BytesIO ( ) np . savez ( bytes_io , normalizer = normalizer ) if not tf . gfile . Exists ( self . _work_dir ) : tf . gfile . MakeDirs ( self . _work_dir ) with tf . gfile . Open ( self . _path , 'wb' ) as f : f . write ( bytes_io . getvalue ( ) ) with tf . gfile . Open ( self . _done_path , 'w' ) as f : f . write ( '' ) return normalizer