tensorflow --Dropout method

tensorflow --Dropout method

import tensorflow as tf
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"]='3'
print(os.environ["TF_CPP_MIN_LOG_LEVEL"])
x=tf.Variable(tf.ones([10,10]))
dro=tf.placeholder(tf.float32)
y=tf.nn.dropout(x,dro)
init=tf.initialize_all_variables()
with tf.Session() as sess:
    sess.run(init)
    print(sess.run(y,feed_dict=({
    
    dro:0.5})))

Insert picture description here
About half of the data of x after being processed by Dropout is set to 0, and the rest of the data is multiplied by 1/keep_prob(keep_prob=dro)
dropout(x,keep_prob,noise_shape,seed,name)

Guess you like

Origin blog.csdn.net/qestion_yz_10086/article/details/108346809