<p dir="auto">I have started <a href="https://github.com/kmalakoff/tensorflow-node">porting Tensorflow to Node.js</a> and was wondering about the status of gradients support in the C and C++ APIs:</p>
<ul dir="auto">
<li><a href="https://www.tensorflow.org/versions/r0.12/how_tos/language_bindings/index.html" rel="nofollow">https://www.tensorflow.org/versions/r0.12/how_tos/language_bindings/index.html</a></li>
<li><a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/resources/roadmap.md">https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/resources/roadmap.md</a></li>
</ul>
<p dir="auto">Could I ask for some help and / or offer some assistance? A couple of ideas:</p>
<ol dir="auto">
<li>I would be happy to test the work-in-progress API in Node.js using either of both <a href="https://github.com/kmalakoff/tensorflow-node/tree/master/src/native/c">C</a> or <a href="https://github.com/kmalakoff/tensorflow-node/tree/master/src/native/cc">C++</a>. I have tried both APIs and would be happy to maintain both as a test case.</li>
<li>I would be happy to receive some guidance from someone on the tensorflow team on how to implement gradients / training without an official API. I see from this issue (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="177892952" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/4473" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/4473/hovercard" href="https://github.com/tensorflow/tensorflow/issues/4473">#4473</a>) that it might be possible, but it has been hard to study the Python and OCAML code to understand what to do. Some pseudocode or links to existing code that would need to replicated could be enough.</li>
<li>Something else? For example, I could help move the gradient API forward by working with someone on the tensorflow team.</li>
</ol>
<p dir="auto">Let me know if you have any suggestions for a path forward. Thank you!</p>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow)</strong>:<br>
No</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>:<br>
OS X EI Caption 10.11.6</li>
<li><strong>TensorFlow installed from (source or binary)</strong>:<br>
binary (pip install)</li>
<li><strong>TensorFlow version (use command below)</strong>:<br>
TensorFlow 1.2.0-rc1 CPU Only</li>
<li><strong>Bazel version (if compiling from source)</strong>:<br>
Build label: 0.4.5-homebrew<br>
Build target: bazel-out/local-<br>
opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar<br>
Build time: Thu Mar 16 13:37:54 2017 (1489671474)<br>
Build timestamp: 1489671474<br>
Build timestamp as int: 1489671474</li>
<li><strong>CUDA/cuDNN version</strong>:<br>
CPU Only</li>
</ul>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">Because of the buffers holding the model weight values are 77MB in size, the memory needed to load these into the app can put a lot of pressure on RAM in Android even before the model is run.<br>
So, I need to further compress the model and round the weights,Even at the expense of accuracy.<br>
So I build <code class="notranslate">/tensorflow/tools/quantization/quantize_graph</code>.There are something wrongs when I run <code class="notranslate">quantize_graph</code> .</p>
<h3 dir="auto">Source code / logs</h3>
<p dir="auto">Source code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bazel-bin/tensorflow/tools/quantization/quantize_graph \
–input=/Users/liba/Desktop/OptimizeCTNModel.pb \
–output=/Users/liba/Desktop/RoundedCTNModel.pb \ 
–output_node_names=output/outputs \
–mode=weights_rounded"><pre class="notranslate"><code class="notranslate">bazel-bin/tensorflow/tools/quantization/quantize_graph \
–input=/Users/liba/Desktop/OptimizeCTNModel.pb \
–output=/Users/liba/Desktop/RoundedCTNModel.pb \ 
–output_node_names=output/outputs \
–mode=weights_rounded
</code></pre></div>
<p dir="auto">log:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/tools/quantization/quantize_graph.py&quot;, line 1301, in &lt;module&gt;
    app.run()
  File &quot;/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/python/platform/app.py&quot;, line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File &quot;/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/tools/quantization/quantize_graph.py&quot;, line 1267, in main
    data = f.read()
  File &quot;/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/python/lib/io/file_io.py&quot;, line 125, in read
    pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
  File &quot;/Users/liba/anaconda/lib/python2.7/contextlib.py&quot;, line 24, in __exit__
    self.gen.next()
  File &quot;/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/python/framework/errors_impl.py&quot;, line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.FailedPreconditionError: .
"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/tools/quantization/quantize_graph.py", line 1301, in &lt;module&gt;
    app.run()
  File "/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/tools/quantization/quantize_graph.py", line 1267, in main
    data = f.read()
  File "/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/python/lib/io/file_io.py", line 125, in read
    pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
  File "/Users/liba/anaconda/lib/python2.7/contextlib.py", line 24, in __exit__
    self.gen.next()
  File "/Users/liba/Desktop/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.FailedPreconditionError: .

</code></pre></div>