Пример #1
0
    def predict_injective_single_example(
            self, eval_saved_model: load.EvalSavedModel,
            raw_example_bytes: bytes) -> types.FeaturesPredictionsLabels:
        """Run predict for a single example for a injective model.

    Args:
      eval_saved_model: EvalSavedModel
      raw_example_bytes: Raw example bytes for the example

    Returns:
      The singular FPL returned by eval_saved_model.predict on the given
      raw_example_bytes.
    """
        fetched_list = eval_saved_model.predict(raw_example_bytes)
        self.assertEqual(1, len(fetched_list))
        self.assertEqual(0, fetched_list[0].input_ref)
        return eval_saved_model.as_features_predictions_labels(fetched_list)[0]
Пример #2
0
    def predict_injective_example_list(
        self, eval_saved_model: load.EvalSavedModel,
        raw_example_bytes_list: List[bytes]
    ) -> List[types.FeaturesPredictionsLabels]:
        """Run predict_list for a list of examples for a injective model.

    Args:
      eval_saved_model: EvalSavedModel
      raw_example_bytes_list: List of raw example bytes

    Returns:
      The list of FPLs returned by eval_saved_model.predict on the given
      raw_example_bytes.
    """
        fetched_list = eval_saved_model.predict_list(raw_example_bytes_list)

        # Check that each FPL corresponds to one example.
        self.assertSequenceEqual(
            range(0, len(raw_example_bytes_list)),
            [fetched.input_ref for fetched in fetched_list])

        return eval_saved_model.as_features_predictions_labels(fetched_list)