예제 #1
0
    def export(self,
               export_dir,
               signature_fn=None,
               input_fn=export.default_input_fn,
               default_batch_size=1,
               exports_to_keep=None):
        """Exports inference graph into given dir.

    Args:
      export_dir: A string containing a directory to write the exported graph
        and checkpoints.
      signature_fn: Function that returns a default signature and a named
        signature map, given `Tensor` of `Example` strings, `dict` of `Tensor`s
        for features and `Tensor` or `dict` of `Tensor`s for predictions.
      input_fn: Function that given `Tensor` of `Example` strings, parses it
        into features that are then passed to the model.
      default_batch_size: Default batch size of the `Example` placeholder.
      exports_to_keep: Number of exports to keep.
    """
        export.export_estimator(estimator=self,
                                export_dir=export_dir,
                                signature_fn=signature_fn,
                                input_fn=input_fn,
                                default_batch_size=default_batch_size,
                                exports_to_keep=exports_to_keep)
예제 #2
0
 def every_n_step_end(self, step, outputs):
   super(ExportMonitor, self).every_n_step_end(step, outputs)
   try:
     export.export_estimator(self._estimator, self.export_dir,
                             exports_to_keep=self.exports_to_keep)
   except RuntimeError:
     # Currently we are not syncronized with saving checkpoints, which leads to
     # runtime errors when we are calling export on the same global step.
     logging.info("Skipping exporting for the same step. "
                  "Consider exporting less frequently.")
예제 #3
0
 def every_n_step_end(self, step, outputs):
     super(ExportMonitor, self).every_n_step_end(step, outputs)
     try:
         export.export_estimator(self._estimator,
                                 self.export_dir,
                                 exports_to_keep=self.exports_to_keep)
     except RuntimeError:
         # Currently we are not syncronized with saving checkpoints, which leads to
         # runtime errors when we are calling export on the same global step.
         logging.info("Skipping exporting for the same step. "
                      "Consider exporting less frequently.")
예제 #4
0
 def end(self, session=None):
   super(ExportMonitor, self).end(session=session)
   latest_path = saver_lib.latest_checkpoint(self._estimator.model_dir)
   if latest_path is None:
     logging.info("Skipping export at the end since model has not been saved "
                  "yet.")
     return
   export.export_estimator(self._estimator,
                           self.export_dir,
                           exports_to_keep=self.exports_to_keep,
                           signature_fn=self.signature_fn,
                           default_batch_size=self._default_batch_size)
예제 #5
0
 def end(self, session=None):
   super(ExportMonitor, self).end(session=session)
   latest_path = saver_lib.latest_checkpoint(self._estimator.model_dir)
   if latest_path is None:
     logging.info("Skipping export at the end since model has not been saved "
                  "yet.")
     return
   export.export_estimator(self._estimator,
                           self.export_dir,
                           exports_to_keep=self.exports_to_keep,
                           signature_fn=self.signature_fn,
                           default_batch_size=self._default_batch_size)
예제 #6
0
  def export(self, export_dir, signature_fn=None,
             input_fn=export.default_input_fn, default_batch_size=1,
             exports_to_keep=None):
    """Exports inference graph into given dir.

    Args:
      export_dir: A string containing a directory to write the exported graph
        and checkpoints.
      signature_fn: Function that returns a default signature and a named
        signature map, given `Tensor` of `Example` strings, `dict` of `Tensor`s
        for features and `Tensor` or `dict` of `Tensor`s for predictions.
      input_fn: Function that given `Tensor` of `Example` strings, parses it
        into features that are then passed to the model.
      default_batch_size: Default batch size of the `Example` placeholder.
      exports_to_keep: Number of exports to keep.
    """
    export.export_estimator(estimator=self,
                            export_dir=export_dir,
                            signature_fn=signature_fn,
                            input_fn=input_fn,
                            default_batch_size=default_batch_size,
                            exports_to_keep=exports_to_keep)
예제 #7
0
 def end(self):
     super(ExportMonitor, self).end()
     export.export_estimator(self._estimator,
                             self.export_dir,
                             exports_to_keep=self.exports_to_keep)
예제 #8
0
 def end(self, session=None):
     super(ExportMonitor, self).end(session=session)
     export.export_estimator(self._estimator,
                             self.export_dir,
                             exports_to_keep=self.exports_to_keep,
                             signature_fn=self.signature_fn)
예제 #9
0
 def end(self, session=None):
   super(ExportMonitor, self).end(session=session)
   export.export_estimator(self._estimator,
                           self.export_dir,
                           exports_to_keep=self.exports_to_keep,
                           signature_fn=self.signature_fn)
예제 #10
0
 def end(self):
   super(ExportMonitor, self).end()
   export.export_estimator(self._estimator, self.export_dir,
                           exports_to_keep=self.exports_to_keep)