Skip to content

GradientTape.gradient returning null #760

Description

@alexhiggins732

I am porting the Keras Actor Critic Method to Tensforflow.net and when I attempt to calculate the gradients it returns null.

using (var tape = tf.GradientTape())
{

    // ....
   
    // relevant code
    float loss_value = actor_losses_sum + critic_losses_sum;
    Tensor loss_value_tensor = tf.convert_to_tensor(loss_value);
    var grads = tape.gradient(loss_value_tensor, model.trainable_variables);
}

I have posted the full source code to reproduce the issue on this [Gist].(https://gist.github.com/alexhiggins732/320286f89e53c3bb3ae291f5979db1f3)

I have research and found several example saying tape.watch may need to be called but I have tried "watching" several tensors with no success.
image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions