Skip to content

GradientTape.gradient returning null #760

@alexhiggins732

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions