2016-05-07 16 views
6

Il seguente codice non dà alcun errore ma non stampa anche il tensore.Perché tf.Print() non stampa in tensorflow

import tensorflow as tf 
import numpy as np 

# Some tensor we want to print the value of 
x = tf.placeholder(tf.float32, shape=[2, 2, 2]) 
a = np.array([[[1.,1.], [1.,1.]], [[2.,2.], [2.,2.]]]) 

m = tf.Print(x,[x]) 

with tf.Session() as sess: 
    sess.run(tf.initialize_all_variables()) 
    m_eval = m.eval(session=sess,feed_dict={x: a}) 

EDIT: dopo la risposta di bgshi, ho scoperto che in consolle ipython, il codice fa stampare il valore tensore. Ma sto usando un notebook iPython. C'è un modo per farlo apparire sul notebook?

+0

ho provato il codice e lo fa stampare il tensore. Io uso tensorflow 0.8, quale versione stai usando? – bgshi

+0

Hmm. Questo è sorprendente. Sto usando anche lo 0.8. Lo sto usando in Ubuntu 14.04. L'ho provato in un notebook ipython. Stai usando anche il notebook ipython? Stampa in linea o viene salvata in un file di registro? –

+0

Sto usando la console. L'output è 'I tensorflow/core/kernel/logging_ops.cc: 79] [1 1 1 ...]'. Quindi è salvato in un file di log, suppongo. – bgshi

risposta

5

Dalla documentazione:

Questa op stampe per l'errore standard. Non è attualmente compatibile con notebook jupyter (stampa per l'output del server notebook, non nel notebook)

tf.print documentation

Problemi correlati