8.Dropout
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data #载入数据集 mnist = input_data.read_data_sets("MNIST_data",one_hot=True) #每个批次的大小 batch_size = 64 #计算一共有多少个批次 n_batch = mnist.train.num_examples // batch_size #定义三个placeholder x = tf.placeholder(tf.float32,[None,784]) y = tf.placeholder(tf.float32,[None,10]) keep_prob=tf.placeholder(tf.float32) # 784-1000-500-10 W1 = tf.Variable(tf.truncated_normal([784,1000],stddev=0.1)) b1 = tf.Variable(tf.zeros([1000])+0.1) L1 = tf.nn.tanh(tf.matmul(x,W1)+b1) L1_drop = tf.nn.dropout(L1,keep_prob) W2 = tf.Variable(tf.truncated