Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何在tensorflow中查看隐藏层的激活值_Python 3.x_Tensorflow_Neural Network - Fatal编程技术网

Python 3.x 如何在tensorflow中查看隐藏层的激活值

Python 3.x 如何在tensorflow中查看隐藏层的激活值,python-3.x,tensorflow,neural-network,Python 3.x,Tensorflow,Neural Network,我使用tensorflow库实现了堆叠式自动编码器。它工作正常。现在我尝试查看隐藏层激活值(y1、y2、y3、y4、y5)。但我没有找到任何办法看到这一点。这是我的密码 x= tf.placeholder(tf.float32,[None,784]) y_=tf.placeholder(tf.float32,[None,6]) k=190 l=180 m=150 n=130 o=100 num_of_epoch=10 w1=tf.Variable(tf.truncated_normal([784

我使用tensorflow库实现了堆叠式自动编码器。它工作正常。现在我尝试查看隐藏层激活值(y1、y2、y3、y4、y5)。但我没有找到任何办法看到这一点。这是我的密码

x= tf.placeholder(tf.float32,[None,784])
y_=tf.placeholder(tf.float32,[None,6])
k=190
l=180
m=150
n=130
o=100
num_of_epoch=10
w1=tf.Variable(tf.truncated_normal([784,k],stddev=0.1))
b1=tf.Variable(tf.zeros([k]))
w2=tf.Variable(tf.truncated_normal([k,l],stddev=0.1))
b2=tf.Variable(tf.zeros([l]))
w3=tf.Variable(tf.truncated_normal([l,m],stddev=0.1))
b3=tf.Variable(tf.zeros([m]))
w4=tf.Variable(tf.truncated_normal([m,n],stddev=0.1))
b4=tf.Variable(tf.zeros([n]))
w5=tf.Variable(tf.truncated_normal([n,o],stddev=0.1))
b5=tf.Variable(tf.zeros([o]))
w6=tf.Variable(tf.truncated_normal([o,6],stddev=0.1))
b6=tf.Variable(tf.zeros([6]))
y1=tf.nn.relu(tf.matmul(x,w1)+b1)
y2=tf.nn.relu(tf.matmul(y1,w2)+b2)
y3=tf.nn.relu(tf.matmul(y2,w3)+b3)
y4=tf.nn.relu(tf.matmul(y3,w4)+b4)
y5=tf.nn.relu(tf.matmul(y4,w5)+b5)
y=tf.nn.softmax(tf.matmul(y5,w6)+b6)
cross_entropy=tf.reduce_mean(-tf.reduce_sum(y_*tf.log(y),
reduction_indices=[1]))
train_step=tf.train.GradientDescentOptimizer(0.1).minimize(cross_entropy)
init=tf.global_variables_initializer()
with tf.Session() as sess:
    sess.run(init)
    for i in range(num_of_epoch):    
        train_data = {x:x_train,y_:y_train}
        sess.run(train_step,feed_dict=train_data)
    currect_prediction=tf.equal(tf.argmax(y,1),tf.argmax(y_,1))
    accuracy=tf.reduce_mean(tf.cast(currect_prediction,tf.float32))
    sess.run(accuracy,feed_dict={x:x_train,y_:y_train})
    currect_prediction=tf.equal(tf.argmax(y,1),tf.argmax(y_,1))
    accuracy=tf.reduce_mean(tf.cast(currect_prediction,tf.float32))
    sess.run(accuracy,feed_dict=   {x:x_test,y_:y_test})
如果你知道的方式,请与我分享或给任何有效的链接,我可以找到答案。提前感谢。

sess.run(y,feed\u dict={x:x\u test})做你想做的事吗?不,不会。