title: Check failed: 1 == NumElements() (1 vs. 1792)Must have a one element tensor in Tensorflow C++
body: <p>In the Python code, the image data is assigned to tensor image_batch:</p>
  <p>Part of the code:</p>
  <pre><code>image_data = misc.imread(image_path)
  
  image_batch = graph.get_tensor_by_name(&quot;input:0&quot;)
  phase_train_placeholder = graph.get_tensor_by_name(&quot;phase_train:0&quot;)
  embeddings = graph.get_tensor_by_name(&quot;embeddings:0&quot;)
  
  feed_dict = {image_batch: np.expand_dims(image_data, 0), phase_train_placeholder: False}
  rep = sess.run(embeddings, feed_dict=feed_dict)
  </code></pre>
  <p>C++ code:</p>
  <pre><code>const float * source_data = (float*) image.data;
  Tensor image_batch(DT_FLOAT, TensorShape({1, 160, 160, 3}));
  auto input = image_batch.tensor&lt;float, 4&gt;();
  for (int y = 0; y &lt; height; ++y) {
      const float* source_row = source_data + (y * width * depth);
      for (int x = 0; x &lt; width; ++x) {
          const float* source_pixel = source_row + (x * depth);
          for (int c = 0; c &lt; depth; ++c) {
              const float* source_value = source_pixel + c;
              //std::cout &lt;&lt; *source_value &lt;&lt; std::endl;
              input(0, y, x, c) = *source_value;
          }
      }
  }
  Tensor phase_train(DT_BOOL, TensorShape());
  phase_train.scalar&lt;bool&gt;()() = false;
  
  std::vector&lt;std::pair&lt;string, tensorflow::Tensor&gt;&gt; inputs = {
      { &quot;input:0&quot;, image_batch },
      { &quot;phase_train:0&quot;, phase_train },
  };    
  std::vector&lt;Tensor&gt; outputs;
  Status run_status = session-&gt;Run(inputs, {&quot;embeddings:0&quot;}, {}, &amp;outputs);
  if (!status.ok()) {
      std::cout &lt;&lt; status.ToString() &lt;&lt; &quot;\n&quot;;
      return 1;
  }
  
  auto output_c = outputs[0].scalar&lt;float&gt;(); //Error here
  
  std::cerr &lt;&lt; &quot;SHOW\n&quot;;
  // Print the results
  std::cout &lt;&lt; outputs[0].DebugString() &lt;&lt; &quot;\n&quot;;
  std::cout &lt;&lt; output_c() &lt;&lt; &quot;\n&quot;; // 30
  </code></pre>
  <p>Err:</p>
  <p>F tensorflow/core/framework/tensor.cc:493] Check failed: 1 == NumElements() (1 vs. 1792)Must have a one element tensor</p>
  <p>Process finished with exit code 6</p>
  <h3>What is the reason for err?</h3>