Skip to content

Monitoring the tf vairables without var.numpy() and "eager execution" #2014

@LordPontiag

Description

@LordPontiag

When you create a TensorFlow variable like this:

alpha = tf.Variable(1.0000, dtype=tf.float32, trainable = False, name="alpha" )

and then want to print it or use it as a regular variable, the most common way is to use variable.numpy(). However, this requires enabling eager execution, which can sometimes interfere with the rest of the code (e.g., in libraries that rely on graph mode). I've found a way to do this without enabling eager execution. You can use this command:

optimized_alpha = model.sess.run(alpha)

instead of this:

optimized_alpha = alpha.numpy()

I hope it helps you
If I'm wrong, correct me please!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions