You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/09/08 19:04:53 UTC

[GitHub] [beam] damccorm commented on a diff in pull request #23087: Support models returning a dictionary of outputs

damccorm commented on code in PR #23087:
URL: https://github.com/apache/beam/pull/23087#discussion_r966325894


##########
sdks/python/apache_beam/ml/inference/pytorch_inference_test.py:
##########
@@ -63,6 +63,17 @@
              for f1, f2 in TWO_FEATURES_EXAMPLES]).reshape(-1, 1))
 ]
 
+TWO_FEATURES_DICT_OUT_PREDICTIONS = [
+    PredictionResult(ex, pred) for ex,
+    pred in zip(
+        TWO_FEATURES_EXAMPLES,
+        [{
+            "output1": torch.Tensor([f1 * 2.0 + f2 * 3 + 0.5]),
+            "output2": torch.Tensor([f1 * 2.0 + f2 * 3 + 0.5])
+        } for f1,
+         f2 in TWO_FEATURES_EXAMPLES])
+]

Review Comment:
   That's probably fine - I was aiming for greater completeness/simplicty modularity/DRY (see subheader [Make Your Tests Complete and Concise](https://abseil.io/resources/swe-book/html/ch12.html) for a more fleshed out philosophy),  but I agree this ends up being better. Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org