question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextClassifier example - AttributeError: 'tuple' object has no attribute 'shape'

See original GitHub issue

Hi,

when trying the IMDB Movie Reviews text classification example I receive the following error message when executing

clf.fit(x_train, y_train)

AttributeError: in user code: C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\keras\engine\training.py:803 train_function *\n return step_function(self, iterator)\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\keras\engine\training.py:793 step_function **\n outputs = model.distribute_strategy.run(run_step, args=(data,))\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:964 run\n return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:2315 call_for_each_replica\n return self._call_for_each_replica(fn, args, kwargs)\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:2674 _call_for_each_replica\n return fn(*args, **kwargs)\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\keras\engine\training.py:786 run_step **\n outputs = model.train_step(data)\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\keras\engine\training.py:756 train_step\n self.compiled_metrics.update_state(y, y_pred, sample_weight)\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\keras\engine\compile_utils.py:389 update_state\n self._build(y_pred, y_true)\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\keras\engine\compile_utils.py:320 _build\n self._metrics, y_true, y_pred)\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\util\nest.py:1131 map_structure_up_to\n **kwargs)\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\util\nest.py:1227 map_structure_with_tuple_paths_up_to\n *flat_value_lists)]\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\util\nest.py:1226 <listcomp>\n results = [func(*args, **kwargs) for args in zip(flat_path_list,\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\util\nest.py:1129 <lambda>\n lambda _, *values: func(*values), # Discards the path arg.\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\keras\engine\compile_utils.py:419 _get_metric_objects\n return [self._get_metric_object(m, y_t, y_p) for m in metrics]\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\keras\engine\compile_utils.py:419 <listcomp>\n return [self._get_metric_object(m, y_t, y_p) for m in metrics]\n C:\Users\Sascha\.conda\envs\keras4\lib\site-packages\tensorflow\python\keras\engine\compile_utils.py:440 _get_metric_object\n y_t_rank = len(y_t.shape.as_list()) AttributeError: ‘tuple’ object has no attribute ‘shape’\n"

I’m using the current tf-nightly 2.3.0.dev20200519 and the current autokeras 1.0.3 on Github. I receive the same error message with tf 2.2 and autokeras 1.0.2, and tf-nightly and autokeras 1.0.2.

I also tried tf 2.1.0 with autokeras 1.0.2, the fit works but then I cannot export/print the best model:

Error in py_call_impl(callable, dots$args, dots$keywords) : AttributeError: ‘TrackableWeightHandler’ object has no attribute ‘shape’

When using tf 2.1.0 with autokeras 1.0.3 I get:

ImportError: cannot import name ‘index_lookup’

upon import of autokeras.

I’m running Python 3.6 on Windows in an isolated conda environment.

Other packages: numpy 1.18.4 pandas 1.0.3 keras-tuner 1.0.1 scikit-learn 0.23.1

Appreciate suggestions on how to get this to run.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
monellzcommented, May 20, 2020

I get the same question when I run the example of MNIST!

0reactions
stale[bot]commented, Sep 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

model.fit AttributeError: 'tuple' object has no attribute 'shape'
I have built a custom generator thats takes two generators with flowfromdataframe and output two input and one label. train_generator_one = ...
Read more >
AttributeError tuple object has no attribute append - Solved
python tutorial: #codefix #python #python tutorialAttributeError ' tuple ' object has no attribute 'append' - SolvedIn this video i have ...
Read more >
solved 'tuple' object has no attribute 'get' - YouTube
attribute error at/ ' tuple ' object has no attribute 'get'
Read more >
arcgis.features module | ArcGIS API for Python
A dictionary of feature attribute values with field names as the key ... class is the primary concept for working with Feature objects...
Read more >
BERT Fine-Tuning Tutorial with PyTorch - Chris McCormick
In this tutorial, we will use BERT to train a text classifier. ... AttributeError: 'str' object has no attribute 'item'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found