      # Various helper methods
      def write_to_log(self, changes):
          """ Write the changes to log file """
          logger.info("Writing sort log to: '%s'", self.args.log_file_path)
          with open(self.args.log_file_path, 'w') as lfile:
              lfile.write(self.serializer.marshal(changes))
  
      def reload_images(self, group_method, img_list):
          """
          Reloads the image list by replacing the comparative values with those
          that the chosen grouping method expects.
 
</s> remove         try:
            logger.info("Writing alignments to: '%s'", self.file)
            with open(self.file, self.serializer.woptions) as align:
                align.write(self.serializer.marshal(self.data))
            logger.debug("Saved alignments")
        except IOError as err:
            logger.error("'%s' not written: %s", self.file, err.strerror)
 </s> add         logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments") </s> remove         try:
            with open(self.filename, "wb") as out:
                state = {"name": self.name,
                         "sessions": self.sessions,
                         "lowest_avg_loss": self.lowest_avg_loss,
                         "iterations": self.iterations,
                         "inputs": self.inputs,
                         "training_size": self.training_size,
                         "config": _CONFIG}
                state_json = self.serializer.marshal(state)
                out.write(state_json.encode("utf-8"))
        except IOError as err:
            logger.error("Unable to save model state: %s", str(err.strerror))
 </s> add         state = {"name": self.name,
                 "sessions": self.sessions,
                 "lowest_avg_loss": self.lowest_avg_loss,
                 "iterations": self.iterations,
                 "inputs": self.inputs,
                 "training_size": self.training_size,
                 "config": _CONFIG}
        self.serializer.save(self.filename, state) </s> remove         try:
            with open(state_file, "rb") as inp:
                state = self.serializer.unmarshal(inp.read().decode("utf-8"))
                self.state = state
                logger.debug("Loaded state: %s", state)
        except IOError as err:
            logger.warning("Unable to load state file. Graphing disabled: %s", str(err))
 </s> add         self.state = self.serializer.load(state_file)
        logger.debug("Loaded state: %s", self.state) </s> remove                                   "{}_state.{}".format(self.model_name, serializer.ext))
        with open(state_file, "rb") as inp:
            state = serializer.unmarshal(inp.read().decode("utf-8"))
            session_names = ["session_{}".format(key)
                             for key in state["sessions"].keys()]
 </s> add                                   "{}_state.{}".format(self.model_name, serializer.file_extension))
        state = serializer.load(state_file)
        session_names = ["session_{}".format(key)
                         for key in state["sessions"].keys()] </s> remove         try:
            logger.info("Reading alignments from: '%s'", self.file)
            with open(self.file, self.serializer.roptions) as align:
                data = self.serializer.unmarshal(align.read())
        except IOError as err:
            logger.error("'%s' not read: %s", self.file, err.strerror)
            exit(1)
 </s> add         logger.info("Reading alignments from: '%s'", self.file)
        data = self.serializer.load(self.file)
        self.serializer.save(self.args.log_file_path, changes)
      # Various helper methods
      def write_to_log(self, changes):
          """ Write the changes to log file """
          logger.info("Writing sort log to: '%s'", self.args.log_file_path)
        self.serializer.save(self.args.log_file_path, changes)
        self.serializer.save(self.args.log_file_path, changes)
  
      def reload_images(self, group_method, img_list):
          """
          Reloads the image list by replacing the comparative values with those
          that the chosen grouping method expects.
keep keep keep keep replace replace keep keep keep keep keep
 Standardize serialization (#903)

* Standardize serialization

- Linting
- Standardize serializer use throughout code
- Extend serializer to load and save files
- Always load and save in utf-8
- Create documentation 
tools/sort.py