You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing the following error message while trying to run the example file autokeras.examples.automodel_with_cnn.py:
2024-11-20 20:24:34.105906: W tensorflow/core/framework/local_rendezvous.cc:404] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence
> /home/humbulani/tensorflow/env/lib/python3.12/site-packages/autokeras/auto_model.py(391)_analyze_data()
-> for analyser in analysers:
(Pdb) c
Traceback (most recent call last):
File "/home/humbulani/tensorflow/examples_auto/automodel_with_cnn.py", line 39, in <module>
auto_model.fit(x_train, y_train, epochs=1)
File "/home/humbulani/tensorflow/env/lib/python3.12/site-packages/autokeras/auto_model.py", line 296, in fit
self._analyze_data(dataset)
File "/home/humbulani/tensorflow/env/lib/python3.12/site-packages/autokeras/auto_model.py", line 392, in _analyze_data
analyser.finalize()
File "/home/humbulani/tensorflow/env/lib/python3.12/site-packages/autokeras/analysers/output_analysers.py", line 80, in finalize
raise ValueError(
ValueError: Expect the target data for classification_head_1 to have shape [2], but got [].
Attempted fixes
I read the file automodel_with_cnn.py and I couldn't find any errors, AutoKeras API usage seems to ok together with functions and classes signatures - so, I don't think the error is on API usage.
I decided to read AutoKeras source code to trace the error with pdb. The error is from the following code snippet from the function ClassificationAnalyser.finalize:
...
# Check shape equals expected shape.expected=self.get_expected_shape()
actual=self.shape[1:]
iflen(actual) ==0:
actual= [1]
ifself.encodedandactual!=expected:
raiseValueError(
"Expect the target data for {name} to have ""shape {expected}, but got {actual}.".format(
name=self.name, expected=expected, actual=self.shape[1:]
)
)
The above code snippet calls the function 'get_expected_shape' reproduced below:
The 'actual local variable is not equal to the expected local variable, so it raises a ValueError exception. I Then decided to force them to be equal by removing not keyword from the line: if self.num_classes == 2 and not self.multi_label:. And it worked. I don't know yet implications of this on the whole codebase but I hope I proper fix can be found.
One implication of the above fix is that we have to include the keyword argument multi_label=True in the instantiation of the classifier: clf = ak.TextClassifier(max_trials=3, multi_label=True) from the example file imdb.py.
Note There are other small issues like numpy dtypes deprecation where we dtypes like str has changed to str_ from example file like imdb.py. I suspect this is probably due to numpy versions.
Tests
I ran only the tests from the analysers directory with no errors.
Describe the bug
I am experiencing the following error message while trying to run the example file
autokeras.examples.automodel_with_cnn.py
:Attempted fixes
I read the file
automodel_with_cnn.py
and I couldn't find any errors,AutoKeras API
usage seems to ok together with functions and classes signatures - so, I don't think the error is on API usage.I decided to read
AutoKeras
source code to trace the error withpdb
. The error is from the following code snippet from the functionClassificationAnalyser.finalize
:The above code snippet calls the function 'get_expected_shape' reproduced below:
The '
actual
local variable is not equal to theexpected
local variable, so it raises aValueError
exception. I Then decided to force them to be equal by removingnot
keyword from the line:if self.num_classes == 2 and not self.multi_label:
. And it worked. I don't know yet implications of this on the whole codebase but I hope I proper fix can be found.One implication of the above fix is that we have to include the keyword argument
multi_label=True
in the instantiation of the classifier:clf = ak.TextClassifier(max_trials=3, multi_label=True)
from the example fileimdb.py
.Note There are other small issues like
numpy
dtypes deprecation where we dtypes likestr
has changed tostr_
from example file likeimdb.py
. I suspect this is probably due tonumpy
versions.Tests
I ran only the tests from the
analysers
directory with no errors.Environment
To reproduce
Please run the
example
files from theautokeras/examples
directory.The text was updated successfully, but these errors were encountered: