<hr>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li>
<p dir="auto"><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow)</strong>:<br>
I used stock example script provided by TensorFlow to write my own custom code.</p>
</li>
<li>
<p dir="auto"><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>:<br>
Windows 10 - Colab Notebook</p>
</li>
<li>
<p dir="auto"><strong>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device</strong>:<br>
N/A</p>
</li>
<li>
<p dir="auto"><strong>TensorFlow installed from (source or binary)</strong>:<br>
Not sure</p>
</li>
<li>
<p dir="auto"><strong>TensorFlow version (use command below)</strong>:<br>
1.9</p>
</li>
<li>
<p dir="auto"><strong>Python version</strong>:<br>
3.6 (I think)</p>
</li>
<li>
<p dir="auto"><strong>Bazel version (if compiling from source)</strong>:<br>
Unsure</p>
</li>
<li>
<p dir="auto"><strong>GCC/Compiler version (if compiling from source)</strong>:<br>
Unsure</p>
</li>
<li>
<p dir="auto"><strong>CUDA/cuDNN version</strong>:<br>
N/A</p>
</li>
<li>
<p dir="auto"><strong>GPU model and memory</strong>:<br>
N/A</p>
</li>
<li>
<p dir="auto"><strong>Exact command to reproduce</strong>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  # Train the CNN model
  mnist_classifier.train(input_fn=train_input_fn,steps=train_steps)"><pre class="notranslate"><code class="notranslate">  # Train the CNN model
  mnist_classifier.train(input_fn=train_input_fn,steps=train_steps)
</code></pre></div>
</li>
</ul>
<p dir="auto">You can collect some of this information using our environment capture script:</p>
<p dir="auto"><a href="https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh">https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh</a></p>
<p dir="auto">You can obtain the TensorFlow version with</p>
<p dir="auto">python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"</p>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request.</p>
<p dir="auto">I want to train multiple CNNs of the same structure (lenet) using randomly selected subsets of varying sizes from the MNIST training set. I was able to use the same line of code successfully in an earlier program. This work is contributing towards the development of a computational model for executive function deficits in ADHD as part of a PhD thesis in Pharmaceutical Sciences.</p>
<h3 dir="auto">Source code / logs</h3>
<p dir="auto">Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.<br>
<a href="https://github.com/tensorflow/tensorflow/files/2214655/Quantitative.WM.Model.txt">Quantitative WM Model.txt</a></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>: Yes</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>: Debian Jessie</li>
<li><strong>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device</strong>: n/a</li>
<li><strong>TensorFlow installed from (source or binary)</strong>: binary</li>
<li><strong>TensorFlow version (use command below)</strong>: ('v1.9.0-0-g25c197e023', '1.9.0')</li>
<li><strong>Python version</strong>: 2.7.9</li>
<li><strong>Bazel version (if compiling from source)</strong>: n/a</li>
<li><strong>GCC/Compiler version (if compiling from source)</strong>: n/a</li>
<li><strong>CUDA/cuDNN version</strong>: n/a</li>
<li><strong>GPU model and memory</strong>: n/a</li>
<li><strong>Exact command to reproduce</strong>: See provided gist</li>
</ul>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">I've been setting up Estimators by using Keras layers to define tensors and then feeding them into my own <code class="notranslate">model_fn</code>. This was a pain and prevented me from easily doing stuff like adding regularization, but was necessary until recently due to various bugs within <code class="notranslate">model_to_estimator</code>. Luckily those bugs have been fixed, and I can now use the much more canonical and proper <code class="notranslate">model_to_estimator</code>. Unfortunately there are still some holes...</p>
<p dir="auto">Anyways, when I did this I would, in defining the model, set various summaries to be collected simply by calling <code class="notranslate">tf.summary.scalar</code> etc. as documented. However, when I take the same tensors and put them through a Keras model and then through <code class="notranslate">model_to_estimator</code>, the summaries I've defined do not get<br>
written.</p>
<p dir="auto">I've tried a few things here, but largely haven't met with any success. One of the workarounds <a href="https://groups.google.com/forum/#!topic/keras-users/rEJ1xYqD3AM" rel="nofollow">I've seen suggested</a> is to try and shove the result of <code class="notranslate">tf.summary.merge_all</code> into a <code class="notranslate">metric</code>, but this does not work since Keras wants those to be numeric and summaries are strings. This does not work if I put this in as <code class="notranslate">target_tensors</code> either, as commented out in the gist.</p>
<p dir="auto">Note: I recognize that this is filed against TF 1.9, but I don't see anything in the 1.10 changelog to indicate that this was noted or fixed. I am in a weird situation where it is best for me to use 1.9, unfortunately.</p>
<h3 dir="auto">Source code / logs</h3>
<p dir="auto">The <a href="https://gist.github.com/zmjjmz/75ba919d5f2755738252b4d0b0032faa">gist</a> here reproduces this issue by taking a common function to get the tensors for a model, and creating estimators in both scenarios.</p>
<p dir="auto">Below is the first event with a summary from each case. It shows that in the 'plain' case, the summary tag <code class="notranslate">class_norm</code> shows up whereas in the <code class="notranslate">keras</code> case it does not. This is the crux of the issue I'm encountering.</p>
<p dir="auto">Plain case:<br>
<code class="notranslate">{'value': [{'simple_value': 1.0, 'tag': u'enqueue_input/queue/enqueue_input/random_shuffle_queuefraction_over_250_of_750_full'}, {'simple_value': 4.119956016540527, 'tag': u'class_norm'}, {'simple_value': 0.6801050901412964, 'tag': u'loss'}]}</code><br>
Keras case:<br>
<code class="notranslate">{'value': [{'simple_value': 1.0, 'tag': u'enqueue_input/queue/enqueue_input/random_shuffle_queuefraction_over_250_of_750_full'}, {'simple_value': 0.8805878758430481, 'tag': u'loss_1'}]}</code></p>