0

I'm trying to make variational autoencoder, and debugging my code.

I have a Tensor x_label1 which is a Tensor("decoder_4/dense_36/BiasAdd:0", shape=(19185, 74), dtype=float32).

But I would like to print this to see all of the values like numpy array.

Is there a way to convert a Tensor into a Numpy array?

Here is my code: https://pastebin.com/7BNbwcxw

I defined x_label1 as:

z_sampled_test = Lambda(sampling, output_shape=(latent_dim,), name='z')([z_mean_encoded, z_log_var_encoded])
x_label1 = decoder(z_sampled_test)
Mohammad Jafar Mashhadi
  • 4,102
  • 3
  • 29
  • 49
mario119
  • 343
  • 3
  • 14
  • Doesn't `tensorflow` have some method or tool to do that? `numpy` doesn't know about `tensorflow` objects. At best it can pretend the `tensor` is some sort of nested list. – hpaulj Mar 05 '20 at 00:15
  • Does this answer your question? [How can I convert a tensor into a numpy array in TensorFlow?](https://stackoverflow.com/questions/34097281/how-can-i-convert-a-tensor-into-a-numpy-array-in-tensorflow) – AMC Mar 05 '20 at 00:31
  • You might also find this useful: https://stackoverflow.com/questions/33633370/how-to-print-the-value-of-a-tensor-object-in-tensorflow. – AMC Mar 05 '20 at 00:32
  • @AMC I have looked at it, but it did not work. When I ```x_label1.eval(session=tf.compat.v1.Session()) ```, it gives me an error, ```ValueError: Cannot use the given session to evaluate tensor: the tensor's graph is different from the session's graph.``` – mario119 Mar 05 '20 at 00:41
  • @hpaulj I guess so, but I don't know how to make it work.. – mario119 Mar 05 '20 at 00:42

0 Answers0