<p dir="auto">As a companion issue to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="429700872" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/27538" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/27538/hovercard" href="https://github.com/tensorflow/tensorflow/issues/27538">#27538</a> with tensorflow 2.0.0a. Script fails with</p>
<blockquote>
<p dir="auto">ValueError: Input 0 of layer dense is incompatible with the layer: its rank is undefined, but the layer requires a defined rank.</p>
</blockquote>
<p dir="auto">in the line</p>
<p dir="auto"><code class="notranslate">  layers.Dense(image_data.num_classes, activation='softmax')</code><br>
<strong>System information</strong></p>
<ul dir="auto">
<li>TensorFlow version:</li>
</ul>
<blockquote>
<p dir="auto">('v1.12.0-9492-g2c319fb415', '2.0.0-alpha0')</p>
</blockquote>
<p dir="auto">using an updated script</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"></pre></div>
<p dir="auto">which also works for tensorflow 1.</p>
<ul dir="auto">
<li>Doc Link: <a href="https://www.tensorflow.org/tutorials/images/hub_with_keras" rel="nofollow">https://www.tensorflow.org/tutorials/images/hub_with_keras</a></li>
</ul>
<p dir="auto"><strong>Describe the documentation issue</strong><br>
The downloaded .py script (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="429700872" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/27538" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/27538/hovercard" href="https://github.com/tensorflow/tensorflow/issues/27538">#27538</a>) fails to run (it's not clear-cut if this is a documentation issue or simply a bug) at</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="model = tf.keras.Sequential([
  feature_extractor_layer,
  layers.Dense(image_data.num_classes, activation='softmax')
])"><pre class="notranslate"><code class="notranslate">model = tf.keras.Sequential([
  feature_extractor_layer,
  layers.Dense(image_data.num_classes, activation='softmax')
])
</code></pre></div>
<p dir="auto"><strong>We welcome contributions by users. Will you be able to update submit a PR (use the <a href="https://www.tensorflow.org/community/documentation" rel="nofollow">doc style guide</a>) to fix the doc Issue?</strong><br>
If it's a doc issue, I'd love to. It could go deeper than that. The same issue appears for the MCVE at stackoverflow: <a href="https://stackoverflow.com/questions/55490885/error-converting-keras-model-to-tfjs-duplicate-weight-name-variable" rel="nofollow">https://stackoverflow.com/questions/55490885/error-converting-keras-model-to-tfjs-duplicate-weight-name-variable</a></p>
<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>OS Platform and Distribution : MacOS 10.13 High Sierra</li>
<li>TensorFlow installed from (source or binary): binary</li>
<li>TensorFlow version: 1.12</li>
<li>Python version: 3.6.x</li>
<li>Installed using : Anaconda 3, version 5.3.1</li>
</ul>
<p dir="auto"><strong>Describe the problem</strong><br>
Actually, my program meet a issue as <a href="https://github.com/tensorflow/tensorflow/issues/23999" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/23999/hovercard">#23999 </a></p>
<p dir="auto">I try to deep into the reason which cause the issue,<br>
and found that when I create a env (name 'py36' in my case) in Anaconda3 with Python 3.6 and install TensorFlow 1.12 ,<br>
there are duplicate files <code class="notranslate">libiomp5.dylib</code> &amp; <code class="notranslate">libmklml.dylib</code> under path<br>
<code class="notranslate">~/anaconda3/envs/py36/lib/python3.6/site-packages/_solib_darwin/_U@mkl_Udarwin_S_S_Cmkl_Ulibs_Udarwin___Uexternal_Smkl_Udarwin_Slib/</code></p>
<p dir="auto">which are same files under path<br>
<code class="notranslate">~/anaconda3/envs/py36/lib</code></p>
<p dir="auto">No matter I delete which one, the program cannot run well.</p>
<p dir="auto"><strong>Provide the exact sequence of commands / steps that you executed before running into the problem</strong></p>
<p dir="auto">Step 1. Install Anaconda 3 (Version 5.3.1)<br>
Step2. Create env using Python 3.6<br>
Step3. Install TensorFlow 1.12 and relative package.</p>
<p dir="auto">BTW, If I create env (name 'py35' ) using Python 3.5, this issue is gone.<br>
There are no folder <code class="notranslate">_solib_darwin</code> be created under <code class="notranslate">~/anaconda3/envs/py35/lib/python3.5/site-packages/</code> and no duplicate files <code class="notranslate">libiomp5.dylib</code> &amp; <code class="notranslate">libmklml.dylib</code></p>
<p dir="auto"><strong>Any other info / logs</strong></p>