简体   繁体   中英

Tensorflow: How to output hidden layer?

Here is my neural network in Tensorflow:

tf.reset_default_graph()

x = tf.placeholder(tf.float32)
x_ = tf.placeholder(tf.float32)
th = tf.placeholder(tf.float32)
th_ = tf.placeholder(tf.float32)

rlu_1 = tf.contrib.layers.fully_connected
rlu_1.num_outputs = 10

# 4 state features: x, x_, th, th_
rlu_1.inputs = [x,x_,th,th_]
rlu_1.weights_initializer = tf.random_uniform(shape=[4],minval=-1,maxval=1) # is this 4 or 10?
rlu_2 = tf.contrib.layers.fully_connected # hope that makes a copy
rlu_2.inputs = rlu_1
rlu_2.num_outputs = 10
rlu_2.weights_initializer = tf.random_uniform(shape=[10],minval=-1,maxval=1)
Qcptr = tf.contrib.layers.fully_connected
Qcptr.inputs = rlu_2
Qcptr.num_outputs = 2
Qcptr.activation_fn = tf.identity

I want to output the values in the last layer. How do I do that? I cannot install tflearn because I am using Anaconda on a Windows machine.

I fixed it! Turns out this I was missing brackets for fully_connected. Instead of rlu_1 = tf.contrib.layers.fully_connected

I should have done rlu_1 = tf.contrib.layers.fully_connected(inputs=..,num_outputs=..)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM