<p dir="auto"><code class="notranslate">tf.nn.conv2d()</code>'s behaviour on throwing the "data_format == FORMAT_NHWC" assertion seems odd. I cooked up a minimal example:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="input_np = np.zeros([1,1,4,4], dtype=np.float32)
x = tf.constant(input_np, dtype=tf.float32)
filter = tf.ones([1,1,1,1], dtype=tf.float32)
out = tf.nn.conv2d(x, filter, [1,1,1,1], padding='SAME', data_format='NCHW')
sess= tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(out)"><pre class="notranslate"><span class="pl-s1">input_np</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">zeros</span>([<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">4</span>,<span class="pl-c1">4</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-s1">float32</span>)
<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">constant</span>(<span class="pl-s1">input_np</span>, <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">tf</span>.<span class="pl-s1">float32</span>)
<span class="pl-s1">filter</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">ones</span>([<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">tf</span>.<span class="pl-s1">float32</span>)
<span class="pl-s1">out</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">nn</span>.<span class="pl-en">conv2d</span>(<span class="pl-s1">x</span>, <span class="pl-s1">filter</span>, [<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>], <span class="pl-s1">padding</span><span class="pl-c1">=</span><span class="pl-s">'SAME'</span>, <span class="pl-s1">data_format</span><span class="pl-c1">=</span><span class="pl-s">'NCHW'</span>)
<span class="pl-s1">sess</span><span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-v">Session</span>()
<span class="pl-s1">sess</span>.<span class="pl-en">run</span>(<span class="pl-s1">tf</span>.<span class="pl-en">global_variables_initializer</span>())
<span class="pl-s1">sess</span>.<span class="pl-en">run</span>(<span class="pl-s1">out</span>)</pre></div>
<p dir="auto">Throws:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="F tensorflow/core/kernels/conv_ops.cc:62] Check failed: data_format == FORMAT_NHWC
Generic conv implementation only supports NHWC tensor format for now.
Aborted (core dumped)"><pre class="notranslate"><code class="notranslate">F tensorflow/core/kernels/conv_ops.cc:62] Check failed: data_format == FORMAT_NHWC
Generic conv implementation only supports NHWC tensor format for now.
Aborted (core dumped)
</code></pre></div>
<p dir="auto">While this works fine, and it uses exactly the same variables, but now I am feeding a placeholder.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="input_np = np.zeros([1,1,4,4], dtype=np.float32)
x = tf.placeholder(&quot;float&quot;, [None, 1,4,4])
filter = tf.ones([1,1,1,1], dtype=tf.float32)
out = tf.nn.conv2d(x, filter, [1,1,1,1], padding='SAME', data_format='NCHW')
sess= tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(out, feed_dict={x:input_np})"><pre class="notranslate"><span class="pl-s1">input_np</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">zeros</span>([<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">4</span>,<span class="pl-c1">4</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-s1">float32</span>)
<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">placeholder</span>(<span class="pl-s">"float"</span>, [<span class="pl-c1">None</span>, <span class="pl-c1">1</span>,<span class="pl-c1">4</span>,<span class="pl-c1">4</span>])
<span class="pl-s1">filter</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">ones</span>([<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">tf</span>.<span class="pl-s1">float32</span>)
<span class="pl-s1">out</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">nn</span>.<span class="pl-en">conv2d</span>(<span class="pl-s1">x</span>, <span class="pl-s1">filter</span>, [<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>], <span class="pl-s1">padding</span><span class="pl-c1">=</span><span class="pl-s">'SAME'</span>, <span class="pl-s1">data_format</span><span class="pl-c1">=</span><span class="pl-s">'NCHW'</span>)
<span class="pl-s1">sess</span><span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-v">Session</span>()
<span class="pl-s1">sess</span>.<span class="pl-en">run</span>(<span class="pl-s1">tf</span>.<span class="pl-en">global_variables_initializer</span>())
<span class="pl-s1">sess</span>.<span class="pl-en">run</span>(<span class="pl-s1">out</span>, <span class="pl-s1">feed_dict</span><span class="pl-c1">=</span>{<span class="pl-s1">x</span>:<span class="pl-s1">input_np</span>})</pre></div>
<p dir="auto">Using 0.12.1, error is consistent across: OS-X as Ubuntu 14.04, regardless of CPU or GPU device placement.</p>
<p dir="auto"><a href="https://developer.nvidia.com/cuda-release-candidate-download" rel="nofollow">https://developer.nvidia.com/cuda-release-candidate-download</a></p>