Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf.debugging & tests for tf.function #304

Open
hstojic opened this issue Jul 19, 2021 · 4 comments
Open

tf.debugging & tests for tf.function #304

hstojic opened this issue Jul 19, 2021 · 4 comments
Labels
code quality Improvements to robustness or maintainability

Comments

@hstojic
Copy link
Collaborator

hstojic commented Jul 19, 2021

This is a follow up on discussion in PR #299 - at the moment we use tf.function for optimizing the model, but users might pass any other piece of code through it e.g. whole BO loop through it. Hence, it would be good to have some tests that (all of) our code can be used within tf.function without errors. Most likely we would have errors, since there is a lot of python code can cause errors within tf.function. This is not a high priority probably, but it could get out of hand with time so perhaps at least we could start testing any new piece of code that we want to merge into develop?

Related to this, we should use tf.debugging everywhere in the code instead of if-else statements with some raise statement that we dominantly use at the moment.

@hstojic hstojic added the code quality Improvements to robustness or maintainability label Jul 19, 2021
@joelberkeley
Copy link
Contributor

joelberkeley commented Jul 27, 2021

the situation is actually much worse than I realised re raise and tf.function. The following test passes

def test_raise_is_incompatible_with_tf_function() -> None:
    @tf.function
    def f(a: tf.Tensor) -> tf.Tensor:
        if a <= tf.constant(0):
            raise ValueError

        return a

    with pytest.raises(ValueError):
        f(tf.constant(1))

which suggests that the ValueError is raised even though the value shouldn't execute the error branch (perhaps due to tracing covering every branch). This suggests that any function that has any standard python exceptions in it cannot work for any arguments with tf.function.

@hstojic
Copy link
Collaborator Author

hstojic commented Jul 30, 2021

thanks for making this concrete, this seems quite indicative about exceptions

@uri-granta
Copy link
Collaborator

uri-granta commented Apr 20, 2023

(connected` to #722)

@uri-granta
Copy link
Collaborator

Bumping this ticket in light of #880.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Improvements to robustness or maintainability
Projects
None yet
Development

No branches or pull requests

3 participants