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

Tape not deleted #3

Open
asokraju opened this issue Jan 14, 2021 · 4 comments
Open

Tape not deleted #3

asokraju opened this issue Jan 14, 2021 · 4 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@asokraju
Copy link
Owner

In the Critic Class, after accessing the gradients in action_gradient method in lines 150-155

    def action_gradient(self, input_state, input_actions):
        var = tf.constant(input_actions)
        with tf.GradientTape(watch_accessed_variables=False) as tape_a:
            tape_a.watch(var)
            prediction_a = self.critic_model([input_state, var])
        return tape_a.gradient(prediction_a, var)

using GradientTape with watch_accessed_variables=False, the tape_a is not deleted. It may cause undesirable behaviors.

@asokraju asokraju added the good first issue Good for newcomers label Jan 14, 2021
@asokraju asokraju self-assigned this Jan 14, 2021
@96RadhikaJadhav
Copy link

@asokraju Did you mean to change the code to below?

def action_gradient(self, input_state, input_actions):
var = tf.constant(input_actions)
with tf.GradientTape(watch_accessed_variables=False):
watch(var)
prediction_a = self.critic_model([input_state, var])
return gradient(prediction_a, var)

@asokraju
Copy link
Owner Author

I can't seem to notice any changes in the code above. Can you please mark the differences.
I want to just del the tape.

@96RadhikaJadhav
Copy link

image

Changing the above code to below:

image

@asokraju
Copy link
Owner Author

asokraju commented Jan 16, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants