<p dir="auto">The get started part has a section MNIST for ML Beginners. In this tutorial you should download the test data via:</p>
<p dir="auto">from tensorflow.examples.tutorials.mnist import input_data<br>
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)</p>
<p dir="auto">Unfortunately that's not working because of an connection error.</p>
<p dir="auto">I was able to run the Inception-v3 model on Android just fine, and I now want to run my own trained TensorFlow model on Android. I'm following the approach from <a href="https://www.tensorflow.org/versions/r0.11/tutorials/image_recognition/index.html" rel="nofollow">TensorFlow's image recognition tutorial</a> and the Android TensorFlow demo, and adapting as necessary. My changes include: (a) integrating Android OpenCV as part of the bazel build (b) using own model and label file and (c) adjusting parameters (img_size, input_mean, input_std, etc.) accordingly.</p>
<p dir="auto">From Android logcat, running my model with the tensorflow android demo app gives:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="E/native: tensorflow_inference_jni.cc:202 Error during inference: Invalid argument: Session was not created with a graph before Run()!
...
E/native: tensorflow_inference_jni.cc:159 Output [output/Softmax:0] not found, aborting!
"><pre class="notranslate"><code class="notranslate">E/native: tensorflow_inference_jni.cc:202 Error during inference: Invalid argument: Session was not created with a graph before Run()!
...
E/native: tensorflow_inference_jni.cc:159 Output [output/Softmax:0] not found, aborting!

</code></pre></div>
<h3 dir="auto">What related GitHub issues or StackOverflow threads have you found by searching the web for your problem?</h3>
<p dir="auto">Own (duplicate) SO thread: <a href="http://stackoverflow.com/questions/40555749/running-own-tensorflow-model-on-android-gives-native-inference-error-session-w" rel="nofollow">http://stackoverflow.com/questions/40555749/running-own-tensorflow-model-on-android-gives-native-inference-error-session-w</a></p>
<h3 dir="auto">Environment info</h3>
<p dir="auto">OS X Yosemite (10.10.5), LGE Nexus 5 (Android 6.0.1), Android SDK 23, Android OpenCV SDK 23, Bazel 0.4.0.</p>
<h3 dir="auto">Steps taken</h3>
<ol dir="auto">
<li>Saved own model's checkpoint (.ckpt) and graph definition (.pb) files separately using <code class="notranslate">tf.train.Saver()</code> then <code class="notranslate">tf.train.write_graph()</code></li>
<li>Froze graph using freeze_graph.py (using bazel), gives 227.5 MB file</li>
<li>Optimized the graph using optimize_for_inference.py (additionally tried strip_unused.py)</li>
<li>Copied frozen, optimized, or stripped graph to android/assets</li>
<li>Doubled the total byte limit using <code class="notranslate">coded_stream.SetTotalBytesLimit()</code> in jni_utils.cc to handle my large model size</li>
<li>Built the tensorflow android app using bazel</li>
<li>Installed on android device using adb and bazel</li>
</ol>
<p dir="auto">As a sanity check, I have tested my model in C++ built with bazel following the tutorial here <a href="https://www.tensorflow.org/versions/r0.8/how_tos/image_retraining/index.html" rel="nofollow">label_image</a>, and my model correctly outputs a prediction. I have also tried playing with the order by which I save my graph def and checkpoint files before freezing, but no change.</p>
<p dir="auto">Any help would be great.<br>
cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/drpngx/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/drpngx">@drpngx</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/andrewharp/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/andrewharp">@andrewharp</a></p>