title: additive Gaussian noise in Tensorflow
body: <p>I'm trying to add Gaussian noise to a layer of my network in the following way.</p>
  
  <pre><code>def Gaussian_noise_layer(input_layer, std):
      noise = tf.random_normal(shape = input_layer.get_shape(), mean = 0.0, stddev = std, dtype = tf.float32) 
      return input_layer + noise
  </code></pre>
  
  <p>I'm getting the error:</p>
  
  <blockquote>
    <p>ValueError: Cannot convert a partially known TensorShape to a Tensor:
    (?, 2600, 2000, 1)</p>
  </blockquote>
  
  <p>My minibatches need to be of different sizes sometimes, so the size of the input_layer tensor will not be known until the execution time.</p>
  
  <p>If I understand correctly, someone answering <a href="https://stackoverflow.com/questions/35289773/cannot-convert-a-partially-converted-tensor-in-tensorflow/35289851#35289851">Cannot convert a partially converted tensor in TensorFlow</a> suggested to set shape to tf.shape(input_layer). However then, when I try to apply a convolutional layer to that noisy layer I get another error:</p>
  
  <blockquote>
    <p>ValueError: dims of shape must be known but is None</p>
  </blockquote>
  
  <p>What is the correct way of achieving my goal of adding Gaussian noise to the input layer of a shape unknown until the execution time?</p>