with tf.Session() as sess:
d = tf.to_float(tf.reshape(tf.range(1,17),[4,4]))
sess.run(tf.global_variables_initializer())
print(sess.run(tf.shape(d)))
print(sess.run(d[0]))
# 矩阵有一半左右的元素变为element/0.5,其余为0
dropout_a44 = tf.nn.dropout(d, 0.5, noise_shape = None)
result_dropout_a44 = sess.run(dropout_a44)
print(result_dropout_a44)
# 行大小相同4,行同为0,或同不为0
dropout_a41 = tf.nn.dropout(d, 0.5, noise_shape = [4,1])
result_dropout_a41 = sess.run(dropout_a41)
print(result_dropout_a41)
# 列大小相同4,列同为0,或同不为0
dropout_a24 = tf.nn.dropout(d, 0.5, noise_shape = [1,4])
result_dropout_a24 = sess.run(dropout_a24)
print(result_dropout_a24)
#不相等的noise_shape只能为1