Skip to content

add base_metrics to metrax#39

Merged
jeffcarp merged 3 commits intomainfrom
avg
Mar 19, 2025
Merged

add base_metrics to metrax#39
jeffcarp merged 3 commits intomainfrom
avg

Conversation

@jshin1394
Copy link
Collaborator

No description provided.

@jshin1394 jshin1394 requested a review from jeffcarp March 18, 2025 23:26
y = jnp.array([2.0, -4.0, 0.0, 0.0])
expected = jnp.array([-5.0, -5.0, 0.0, 0.0])
result = base_metrics.divide_no_nan(x, y)
self.assertTrue(jnp.array_equal(result, expected))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Optional) I think all the above tests can be wrapped up in one method using @parameterized.named_parameters as below

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified to @parameterized.named_parameters. Now the inputs were modified to become np array because of this error:

Inside google3, JAX functions cannot be called before InitGoogle() runs, which typically happens inside the call to absl.app.run() inside your program's main() function. Typically this means that you are attempting to manipulate JAX arrays from the top level of your Python program. You must defer such computations until after main() by putting them inside a function, or use classic NumPy arrays instead.

@@ -0,0 +1,60 @@
# Copyright 2024 Google LLC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you feel about calling this base.py (since it's not just metrics)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified to base.py

@jeffcarp jeffcarp merged commit 8df85ea into main Mar 19, 2025
5 checks passed
@jshin1394 jshin1394 deleted the avg branch March 25, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants