Esempio n. 1
0
    def _build_eval_spec(self):
        invoke_args = self._resolve_input_fn_args(
            self.customer_script.eval_input_fn)
        eval_input_fn = lambda: self.customer_script.eval_input_fn(**
                                                                   invoke_args)

        if self.saves_training():
            serving_input_receiver_fn = lambda: self.customer_script.serving_input_fn(
                self.customer_params)
            exporter = tf.estimator.LatestExporter(
                'Servo', serving_input_receiver_fn=serving_input_receiver_fn)
        else:
            logger.warn(
                'serving_input_fn not specified, model NOT saved, use checkpoints to reconstruct'
            )
            exporter = None

        valid_eval_keys = ['start_delay_secs', 'throttle_secs']
        eval_params = {
            k: v
            for k, v in self.customer_params.items() if k in valid_eval_keys
        }

        return tf.estimator.EvalSpec(eval_input_fn,
                                     steps=self.eval_steps,
                                     exporters=exporter,
                                     **eval_params)
    def _build_eval_spec(self):
        # TODO: why is this different from the train_input_fn? investigate
        input_dir = self.input_channels.get(self.DEFAULT_TRAINING_CHANNEL,
                                            None)
        params = self.customer_params
        eval_input_fn = lambda: self.customer_script.eval_input_fn(
            input_dir, params)

        if self.saves_training():
            serving_input_receiver_fn = lambda: self.customer_script.serving_input_fn(
                params)
            exporter = tf.estimator.LatestExporter(
                'Servo', serving_input_receiver_fn=serving_input_receiver_fn)
        else:
            logger.warn(
                'serving_input_fn not specified, model NOT saved, use checkpoints to reconstruct'
            )
            exporter = None

        valid_eval_keys = ['start_delay_secs', 'throttle_secs']
        eval_params = {
            k: v
            for k, v in self.customer_params.items() if k in valid_eval_keys
        }

        return tf.estimator.EvalSpec(eval_input_fn,
                                     steps=self.eval_steps,
                                     exporters=exporter,
                                     **eval_params)
 def _export_strategy():
     if self.saves_training():
         return [saved_model_export_utils.make_export_strategy(
             serving_input_fn=_serving_input_fn,
             default_output_alternative_key=None,
             exports_to_keep=1)]
     logger.warn("serving_input_fn not specified, model NOT saved, use checkpoints to reconstruct")
     return None
 def _export_strategy():
     if self.saves_training():
         return [saved_model_export_utils.make_export_strategy(
             serving_input_fn=_serving_input_fn,
             default_output_alternative_key=None,
             exports_to_keep=1)]
     logger.warn("serving_input_fn not specified, model NOT saved, use checkpoints to reconstruct")
     return None
    def _build_eval_spec(self):
        invoke_args = self._resolve_input_fn_args(self.customer_script.eval_input_fn)
        eval_input_fn = lambda: self.customer_script.eval_input_fn(**invoke_args)

        if self.saves_training():
            serving_input_receiver_fn = lambda: self.customer_script.serving_input_fn(self.customer_params)
            exporter = tf.estimator.LatestExporter('Servo',
                                                   serving_input_receiver_fn=serving_input_receiver_fn)
        else:
            logger.warn('serving_input_fn not specified, model NOT saved, use checkpoints to reconstruct')
            exporter = None

        valid_eval_keys = ['start_delay_secs', 'throttle_secs']
        eval_params = {k: v for k, v in self.customer_params.items() if k in valid_eval_keys}

        return tf.estimator.EvalSpec(eval_input_fn, steps=self.eval_steps, exporters=exporter, **eval_params)