Tensorflow c++, issue with tensors and feeding
<p>I am very new to TensorFlow C++ API and trying to just build a very simple graph in Python and load/test it in C++ API. Here is the python code to create the graph:</p>

<pre><code>with tf.Session() as sess: 
   a = tf.placeholder(tf.float32, shape=[2,2], name='a')
   b = tf.placeholder(tf.float32, shape=[2,2], name='b')
   c = tf.matmul(a, b, name="c")

   sess.run(tf.initialize_all_variables())

tf.train.write_graph(sess.graph_def, 'models/', 'graph.pb', as_text=False)
</code></pre>

<p>and here is the C code to load and run the graph:</p>

<pre><code>Tensor a(DT_FLOAT, TensorShape({2,2}));

Tensor b(DT_FLOAT, TensorShape({2,2}));
std::vector&lt;std::pair&lt;string, tensorflow::Tensor&gt;&gt; inputs = {
  { "a", a },
  { "b", b },
};

std::vector&lt;tensorflow::Tensor&gt; outputs;

status = session-&gt;Run(inputs, {"c"}, {}, &amp;outputs);
</code></pre>

<p>However I get this error message:</p>

<blockquote>
  <p>./tensorflow/core/framework/tensor.h:500] Check failed: 1 ==
  NumElements() (1 vs. 4)Must have a one element tensor</p>
</blockquote>

<p>What could be the problem? I noticed if I define my tensors in he python and C++ as [1,1], it goes through without any problem!</p>