mathetes mathetes - 1 year ago 778
Python Question

How can I convert a tensor into a numpy array in TensorFlow?

I know how to convert a numpy array into a tensor object with the function

tf.convert_to_tensor(img.eval())
.

My problem is that after I apply some preprocessing to this tensors in terms of brightness, contrast, etc, I would like to view the resulting transformations to evaluate and tweak my parameters.

How can I convert a tensor into a numpy array so I can show it as an image with PIL?

Answer Source

To convert back from tensor to numpy array you can simply run .eval() on the transformed tensor.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download