Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it tensorflow example bug ? #22595

Closed
Q82822 opened this issue Sep 28, 2018 · 9 comments
Closed

is it tensorflow example bug ? #22595

Q82822 opened this issue Sep 28, 2018 · 9 comments
Assignees
Labels
stat:awaiting tensorflower Status - Awaiting response from tensorflower type:docs-bug Document issues

Comments

@Q82822
Copy link

Q82822 commented Sep 28, 2018

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): window10 and jupyter
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: iPhone X
TensorFlow installed from (source or binary): source
TensorFlow version (use command below): 1.11
Python version: 3.6
Bazel version (if compiling from source):
GCC/Compiler version (if compiling from source):
CUDA/cuDNN version: 9.1 / 7.1
GPU model and memory:
Exact command to reproduce:

Describe the problem

I used the tensorflow github example form here change the CNN model
img = tf.keras.applications.inception_v3.preprocess_input(img) --->img = tf.keras.applications.inception_resnet_v2.preprocess_input(img)

image_model = tf.keras.applications.InceptionV3(include_top=False, weights='imagenet') ---->image_model =tf.keras.applications.InceptionResNetV2(include_top=False, weights='imagenet')

the output

Epoch 1 Batch 0 Loss nan
Epoch 1 Batch 100 Loss nan
Epoch 1 Batch 200 Loss nan
Epoch 1 Batch 300 Loss nan
Epoch 1 Loss nan

i have tried to change the learning rate and loss function,even others CNN model (vgg19,vgg16) but it was same

Source code / logs

the Source code is tensorflow example from here
you just need to change the CNN model and wait a few minute run it.

@Harshini-Gadige
Copy link

@drpngx Hi, could you please look into this issue.

@drpngx
Copy link
Contributor

drpngx commented Oct 2, 2018

@Harshini-Gadige did you try without modifications?

@Harshini-Gadige
Copy link

Harshini-Gadige commented Oct 2, 2018

@drpngx Yes I tried the original one and it took long time to load the data and then the system crashed.

@drpngx
Copy link
Contributor

drpngx commented Oct 2, 2018

@MarkDaoust Is that a known documentation problem?

@Q82822
Copy link
Author

Q82822 commented Oct 3, 2018

@drpngx So this example only can use InceptionV3 Model? have any solution?

thanks!

@drpngx drpngx added the type:docs-bug Document issues label Oct 3, 2018
@drpngx
Copy link
Contributor

drpngx commented Oct 3, 2018

I think it's probably that the docs need to be refreshed. I'm not sure what's the plan for this.

@Harshini-Gadige
Copy link

@MarkDaoust Hi, could you please look into this ?

@Q82822
Copy link
Author

Q82822 commented Nov 9, 2018

hi, this problem was figure out in new tensorflow 1.12 , but it stall have another problem.
In this code will print error
"provided list of inputs contains objects other than 'EagerTensor'. Item 0 is Tensor"
add it happen in use Vgg16 model.

This is the code here
change the CNN model

img = tf.keras.applications.inception_v3.preprocess_input(img) --->img = tf.keras.applications.vgg16.preprocess_input(img)

image_model = tf.keras.applications.InceptionV3(include_top=False, weights='imagenet') ---->image_model =tf.keras.applications.Vgg16(include_top=False, weights='imagenet')

 img = tf.image.resize_images(img, (299, 299))---> img = tf.image.resize_images(img, (224, 224))

change the image features_shape & attention_features_shape

features_shape = 2048 -->512
attention_features_shape = 64-->81

problem code in here

# captions on the validation set
rid = np.random.randint(0, len(img_name_val))
image = img_name_val[rid]
real_caption = ' '.join([index_word[i] for i in cap_val[rid] if i not in [0]])
result, attention_plot = evaluate(image)

print ('Real Caption:', real_caption)
print ('Prediction Caption:', ' '.join(result))
plot_attention(image, result, attention_plot)
# opening the image
`Image.open(img_name_val[rid])`

and error here

FallbackException                        Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py in reshape(tensor, shape, name)
   6494         _ctx._context_handle, _ctx._eager_context.device_name, "Reshape",
-> 6495         name, _ctx._post_execution_callbacks, tensor, shape)
   6496       return _result

_FallbackException: This function does not handle the case of the path where all inputs are not already EagerTensors.

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-31-98d70c233c4f> in <module>()
      2 image = img_name_val[rid]
      3 real_caption = ' '.join([index_word[i] for i in cap_val[rid] if i not in [0]])
----> 4 result, attention_plot = evaluate(image)
      5 
      6 print ('Real Caption:', real_caption)

<ipython-input-29-55980383ccd6> in evaluate(image)
      4     hidden = decoder.reset_state(batch_size=1)
      5 
----> 6     temp_input = tf.expand_dims(load_image(image)[0], 0)
      7     img_tensor_val = image_features_extract_model(temp_input)
      8     img_tensor_val = tf.reshape(img_tensor_val, (img_tensor_val.shape[0], -1, img_tensor_val.shape[3]))

<ipython-input-5-28f690dfd033> in load_image(image_path)
      3     img = tf.image.decode_jpeg(img, channels=3)
      4     img = tf.image.resize_images(img, (224, 224))
----> 5     img = tf.keras.applications.vgg16.preprocess_input(img)
      6     return img, image_path

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/applications/__init__.py in wrapper(*args, **kwargs)
     68       kwargs['models'] = models
     69       kwargs['utils'] = utils
---> 70     return base_fun(*args, **kwargs)
     71   return wrapper
     72 

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/applications/vgg16.py in preprocess_input(*args, **kwargs)
     42 @keras_modules_injection
     43 def preprocess_input(*args, **kwargs):
---> 44   return vgg16.preprocess_input(*args, **kwargs)

/usr/local/lib/python3.6/dist-packages/keras_applications/imagenet_utils.py in preprocess_input(x, data_format, mode, **kwargs)
    193     else:
    194         return _preprocess_symbolic_input(x, data_format=data_format,
--> 195                                           mode=mode, **kwargs)
    196 
    197 

/usr/local/lib/python3.6/dist-packages/keras_applications/imagenet_utils.py in _preprocess_symbolic_input(x, data_format, mode, **kwargs)
    149             data_format=data_format)
    150     else:
--> 151         x = backend.bias_add(x, _IMAGENET_MEAN, data_format)
    152     if std is not None:
    153         x /= std

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/backend.py in bias_add(x, bias, data_format)
   4595     elif data_format == 'channels_last':
   4596       if len(bias_shape) == 1:
-> 4597         x = x + reshape(bias, (1, 1, bias_shape[0]))
   4598       else:
   4599         x = x + reshape(bias, (1,) + bias_shape)

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/backend.py in reshape(x, shape)
   2279       A tensor.
   2280   """
-> 2281   return array_ops.reshape(x, shape)
   2282 
   2283 

/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py in reshape(tensor, shape, name)
   6497     except _core._FallbackException:
   6498       return reshape_eager_fallback(
-> 6499           tensor, shape, name=name, ctx=_ctx)
   6500     except _core._NotOkStatusException as e:
   6501       if name is not None:

/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py in reshape_eager_fallback(tensor, shape, name, ctx)
   6516   _attrs = ("T", _attr_T, "Tshape", _attr_Tshape)
   6517   _result = _execute.execute(b"Reshape", 1, inputs=_inputs_flat, attrs=_attrs,
-> 6518                              ctx=_ctx, name=name)
   6519   _execute.record_gradient(
   6520       "Reshape", _inputs_flat, _attrs, _result, name)

/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
     58     tensors = pywrap_tensorflow.TFE_Py_Execute(ctx._handle, device_name,
     59                                                op_name, inputs, attrs,
---> 60                                                num_outputs)
     61   except core._NotOkStatusException as e:
     62     if name is not None:

TypeError: provided list of inputs contains objects other than 'EagerTensor'. Item 0 is Tensor

THX!!

@Harshini-Gadige Harshini-Gadige added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Nov 9, 2018
@yashk2810
Copy link
Member

Can you try this out: https://www.tensorflow.org/tutorials/text/image_captioning

I am closing this. Please reopen if still failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting tensorflower Status - Awaiting response from tensorflower type:docs-bug Document issues
Projects
None yet
Development

No branches or pull requests

5 participants