Created
March 11, 2017 08:04
-
-
Save roopalgarg/919462c03e6b6fa7c0a3f7a070f33491 to your computer and use it in GitHub Desktop.
tensorflow: add noise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
def gaussian_noise_layer(input_layer, std): | |
noise = tf.random_normal(shape=tf.shape(input_layer), mean=0.0, stddev=std, dtype=tf.float32) | |
return input_layer + noise | |
inp = tf.placeholder(tf.float32, shape=[None, 8], name='input') | |
noise = gaussian_noise_layer(inp, .2) | |
noise.eval(session=tf.Session(), feed_dict={inp: np.zeros((4, 8))}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment