TensorFlow中的手动退出

时间:2018-07-24 13:47:50

标签: tensorflow neural-network deep-learning dropout

我已经定义了一个TensorFlow神经网络,如下所示:

W1 = tf.Variable(tf.truncated_normal([no_features, neurons_hd1], stddev=0.03), name='W1')
b1 = tf.Variable(tf.truncated_normal([neurons_hd1]), name='b1')
...
W5 = tf.Variable(tf.truncated_normal([neurons_hd4, no_outputs], stddev=0.03), name='W5')
b5 = tf.Variable(tf.truncated_normal([no_outputs]), name='b4')

hidden1_out = tf.nn.relu(tf.add(tf.matmul(x, W1), b1))
...
y_ = tf.nn.tanh(tf.add(tf.matmul(hidden4_out, W5), b5))

loss = tf.losses.mean_squared_error(y, y_)
optimizer = tf.train.GradientDescentOptimizer(learning_rate=learning_rate).minimize(loss)

然后我使用以下方法进行训练:

... = sess.run([optimizer, loss], feed_dict={x: batch_x, y: batch_y})

我想申请“手动”退学;我需要从W1,W2,...,W5务实地挑选“特定”权重以退出。如何使用TensorFlow做到这一点?

0 个答案:

没有答案