tensorflow --Dropout方法
程序员文章站
2024-03-15 11:39:53
...
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})))
输出经过Dropout处理后的x将近一半左右的数据置0,其余数据都乘以1/keep_prob(keep_prob=dro)
dropout(x,keep_prob,noise_shape,seed,name)
上一篇: TF-IDF权重策略