C3W4 Lab2 Import error

Hello,

I’m trying to get started on the Model Analysis with TFX Evaluator lab and getting an error on import.

(or in text)

AttributeError Traceback (most recent call last)
in
3
4 import tensorflow as tf
----> 5 import tensorflow_model_analysis as tfma
6 from tfx import v1 as tfx
7

21 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_estimator/python/estimator/estimator.py in
68
69 @estimator_export(v1=[‘estimator.Estimator’])
—> 70 @doc_controls.inheritable_header("""
71 Warning: Estimators are not recommended for new code. Estimators run
72 v1.Session-style code which is more difficult to write correctly, and

AttributeError: module ‘tensorflow.tools.docs.doc_controls’ has no attribute ‘inheritable_header’

If you look at stack overflow, it appears that a new version came out and there is now an incompatibility. Is there a way to fix this?

Thanks!

I have the same problem, it seems to be some incompatibility among installed packages. Did you find any hints on how to resolve this?

I also encountered the same issue. I replaced
“!pip install -U tfx==1.3”
with
“!pip install -U pip
!pip install tensorflow_data_validation==1.1.0
!pip install tensorflow-transform==1.0.0
!pip install tensorflow-model-analysis==0.32.0” for C3W4 Lab1

It then works.

Thank you! That fixed my problem. I get a bunch of errors later on in the lab when calling the Evaluator ("‘NoneType’ object has no attribute ‘wrapped’" , probably due to an NPE somewhere), but it doesn’t seem to stop the Evaluator from working. I was able to run the lab.

It helped also to me, thanks a lot. How did you find that these specific versions of libraries work for this case?

Hi everyone! Colab updated its default packages (e.g. TF 2.6 to TF 2.7) and that might be the cause of this issue. We updated the notebooks just now to downgrade two packages based on the advice in this post

!pip install -U pip
!pip install -U tfx==1.3.1

!pip install --upgrade tensorflow-estimator==2.6.0
!pip install --upgrade keras==2.6.0

You should see the changes when you reopen the notebook from the classroom. The lab should now work but we hope this workaround won’t be necessary in the next TFX release. Hope it also works for you!

Hi @chris.favila ,

This problem is also in lab1, but your version’s lines don’t help there with the dependencies problems…

Hello Chris,

followed up with these versions but for some reason get the following error when running StatisticsGen:

TypeCheckError: Output type hint violation at WriteStatsOutput[train]: expected <class ‘apache_beam.pvalue.PDone’>, got <class ‘str’>
Full type hint:
IOTypeHints[inputs=((<class ‘tensorflow_metadata.proto.v0.statistics_pb2.DatasetFeatureStatisticsList’>,), {}), outputs=((<class ‘apache_beam.pvalue.PDone’>,), {})]
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/usr/local/lib/python3.7/dist-packages/tensorflow_data_validation/api/stats_api.py”, line 113, in
class WriteStatisticsToBinaryFile(beam.PTransform):
File “/usr/local/lib/python3.7/dist-packages/apache_beam/typehints/decorators.py”, line 776, in annotate_input_types
*converted_positional_hints, **converted_keyword_hints)

based on:
IOTypeHints[inputs=None, outputs=((<class ‘apache_beam.pvalue.PDone’>,), {})]
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/usr/local/lib/python3.7/dist-packages/tensorflow_data_validation/api/stats_api.py”, line 113, in
class WriteStatisticsToBinaryFile(beam.PTransform):
File “/usr/local/lib/python3.7/dist-packages/apache_beam/typehints/decorators.py”, line 863, in annotate_output_types
f._type_hints = th.with_output_types(return_type_hint) # pylint: disable=protected-access

Hi Tapani! Welcome to the community! Sorry for the late reply. There was an issue with the apache beam version that Colab was using. This should now be fixed. Kindly reopen the notebook from the classroom. Thanks!