tensorflow --Dropout方法

tensorflow --Dropout方法

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})))

tensorflow --Dropout方法_第1张图片
输出经过Dropout处理后的x将近一半左右的数据置0,其余数据都乘以1/keep_prob(keep_prob=dro)
dropout(x,keep_prob,noise_shape,seed,name)

你可能感兴趣的:(深度学习,tensorflow,python)