<p dir="auto"><strong>System information</strong><br>
-Google Colab<br>
-GPU<br>
-Python 3<br>
-Tensorflow tf-nightly-2.0-preview</p>
<p dir="auto">When I write the code:<br>
<code class="notranslate">from __future__ import absolute_import, division, print_function</code><br>
<code class="notranslate">!pip install tf-nightly-2.0-preview</code><br>
<code class="notranslate">import tensorflow as tf</code><br>
<code class="notranslate">tf.enable_eager_execution()</code><br>
It gives me the error <strong>AttributeError: 'module' object has no attribute 'enable_eager_execution'</strong></p>
<p dir="auto">whereas when I simply run the code as:<br>
<code class="notranslate">from __future__ import absolute_import, division, print_function</code><br>
<code class="notranslate">!pip install tf-nightly-2.0-preview</code><br>
<code class="notranslate">import tensorflow as tf</code><br>
<code class="notranslate">tf.executing_eagerly()</code><br>
It returns <strong>'True'</strong>, which means that eager execution is working by default without even enabling it before.<br>
If I proceed without using tf.enable_eager_execution() in this collab tutorial <a href="url">https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/r2/tutorials/generative/image_captioning.ipynb#scrollTo=U8l4RJ0XRPEm</a><br>
In the cell Caching the features extracted from InceptionV3,<br>
the last line with "np.save(path_of_feature, bf.numpy())" gives me an error saying <strong>"Tensor has no attribute called numpy()"</strong><br>
If I see the type() of batch_features in the line:<br>
<code class="notranslate">batch_features = image_features_extract_model(img)</code> line is returning a graph tensor, instead of an eager tensor. It's not supposed to do that. Does this means that eager execution is not yet enabled or is this a bug.</p>
<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>Have I written custom code (as opposed to using a stock example script provided in TensorFlow): NO</li>
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04):Colab</li>
<li>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:</li>
<li>TensorFlow installed from (source or binary): pip</li>
<li>TensorFlow version (use command below): <strong>2.0</strong></li>
<li>Python version:3.x</li>
</ul>
<p dir="auto"><strong>Describe the current behavior</strong><br>
When running the code in</p>
<blockquote>
<p dir="auto">Caching the features extracted from InceptionV3<br>
AttributeError: 'Tensor' object has no attribute 'numpy'</p>
</blockquote>
<p dir="auto"><strong>Describe the expected behavior</strong></p>
<p dir="auto"><strong>Code to reproduce the issue</strong><br>
Provide a reproducible test case that is the bare minimum necessary to generate the problem.<br>
for img, path in tqdm(image_dataset):<br>
batch_features = image_features_extract_model(img)<br>
batch_features = tf.reshape(batch_features,<br>
(batch_features.shape[0], -1, batch_features.shape[3]))</p>
<p dir="auto">for bf, p in zip(batch_features, path):<br>
path_of_feature = p.numpy().decode("utf-8")<br>
np.save(path_of_feature, bf.numpy())<br>
<strong>Other info / logs</strong></p>
<p dir="auto">AttributeError                            Traceback (most recent call last)<br>
 in ()<br>
15   for bf, p in zip(batch_features, path):<br>
16     path_of_feature = p.numpy().decode("utf-8")<br>
---&gt; 17     np.save(path_of_feature, bf.numpy())</p>
<p dir="auto">AttributeError: 'Tensor' object has no attribute 'numpy'</p>