How to store printed values from tf.print into a text file

1,853 views
Skip to first unread message

dia...@gmail.com

unread,
Aug 29, 2016, 11:12:29 AM8/29/16
to Discuss
Hello guys, I'm trying to print the values of an LSTM forget gate in a text file:

When I do:

f = tf.Print(f, [f], message="This is f: ", summarize=120)

... I receive by console the result in numbers

However when I try to store this data using:

with open("test.txt", "a") as myfile:
                myfile.write(str(tf.Print(f, [f], message="This is f: ", summarize=120)))

In the text file I just receive per processed data,

Tensor("RNN/LayerNormalizedLSTMCell_5/Print_1:0", shape=(?, 10), dtype=float32)

Could you tell me please how solve this?

Thanks

Jordi

unread,
Aug 29, 2016, 7:53:32 PM8/29/16
to Discuss, dia...@gmail.com
Hello Dialgop,


- "This is an identity op with the SIDE EFFECT of printing data when evaluating."

I guess that it will write it on the "cout" channel, so you could try to redirect the output of the execution to a file using the console. If not, you can not use that functions to print into a file.

Dmytro Filatov

unread,
Nov 17, 2016, 4:02:14 PM11/17/16
to Discuss, dia...@gmail.com
Hi DialGop,
Did you found a good solution for this? Have you tried to experiment with tf.py_func?
Please let me know if you will find the good way to do this.
Thanks

On Monday, 29 August 2016 08:12:29 UTC-7, dia...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages