Tensorflow AdamOptimizer throws error when variable has validate_shape=False
<p>Tensorflow's AdamOptimizer is throwing an error for me when any trainable variables have the "validate_shape" argument set to False. I set this argument to false to allow a dynamic batch size at runtime. </p>

<pre><code>~/anaconda/lib/python3.5/site-packages/tensorflow/python/framework/tensor_shape.py in as_list(self)
    774     """
    775     if self._dims is None:
--&gt; 776       raise ValueError("as_list() is not defined on an unknown TensorShape.")
    777     return [dim.value for dim in self._dims]
    778 

ValueError: as_list() is not defined on an unknown TensorShape.
</code></pre>

<p>I cannot reproduce this error with GradientDescentOptimizer but all other optimizers in Tensorflow throw the same error. </p>

<pre><code>opt = tf.train.AdamOptimizer()

X = tf.placeholder(tf.float64, shape=[None, None], name='X')
Y = tf.placeholder(tf.float64, shape=[None, 1], name='Y')
B = tf.Variable(initial_value=tf.zeros([tf.shape(X)[1], 1], dtype=tf.float64), validate_shape=False, name='B')

prediction = tf.matmul(X, B)
loss = tf.reduce_sum((Y- prediction) ** 2)
opt_op = opt.minimize(loss)
</code></pre>

<p>Is there a reason why GradientDescentOptimizer seems to support dynamic variable shapes at runtime but the other optimizers do not?</p>

<p>Full repro at: <a href="https://github.com/narner90/scratchpad/blob/master/AdamOptimizerValidateShape.ipynb" rel="nofollow noreferrer">https://github.com/narner90/scratchpad/blob/master/AdamOptimizerValidateShape.ipynb</a></p>