Machine Learning with Python Projects - Neural Network SMS Text Classifier

Tell us what’s happening:
Google Colab seems to be having an issue importing/installing tensorflow_datasets. Without it, completing the SMS challenge is impossible.

For details, this occurs in the main google colab without edited code blocks. Here is the exact error:

TypeError                                 Traceback (most recent call last)
<ipython-input-1-de4264bf5fd5> in <module>
      9 from tensorflow import keras
     10 get_ipython().system('pip install tensorflow-datasets')
---> 11 import tensorflow_datasets as tfds
     12 import numpy as np
     13 import matplotlib.pyplot as plt

10 frames
/usr/local/lib/python3.8/dist-packages/google/protobuf/ in __new__(cls, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options, serialized_options, has_default_value, containing_oneof, json_name, file, create_key)
    559       else:
    560         return _message.default_pool.FindFieldByName(full_name)
--> 561 
    562   def __init__(self, name, full_name, index, number, type, cpp_type, label,
    563                default_value, message_type, enum_type, containing_type,

TypeError: Descriptors cannot not be created directly.
If this call came from a file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

Your code so far
Here are the different ways that I tried to solve this issue:

!pip install -q tfds-nightly tensorflow # tried force installing tensorflow
!pip install --upgrade tensorflow # updated to latest version of tensorflow
!pip install protobuf==4.21.0 # updated protobug

I placed these in the top/first code block, but none of them worked.

Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Machine Learning with Python Projects - Neural Network SMS Text Classifier

Link to the challenge:

You just need tensorflow or whatever neural network libraries and dependencies you decide to use. I just rechecked the boilerplate and it doesn’t explicitly use tensorflow datasets and I’m not sure why it’s imported in the boilerplate.


and this

are quite likely incompatible as that is not 3.20.x or lower, but I have no further diagnosis of the error.

Yeah, just FYI I’m here researching the same error. Just starting this project, and yeah, the import of tensorflow_datasets has failed with that error. I haven’t looked into it yet as I figured I’d check here first… guessing some version compatibility issue as ran into several version issues throughout the course where the coursework was no longer valid. But yeah, not just you having the problem, I’ll let you know if I find an easy fix, although may just attempt to complete the project without that package…

1 Like

OK, I figured it was a newer version conflict, and apparently tf-nightly installs all the latest stuff up to yesterday, so I started over, and commented out the tf-nightly install, and everything else then installed/imported without issue.


Not sure if this is going to cause an issue… most likely not because as this sheet was created years ago I’m guessing it doesn’t need newest version of anything, but if this does end up causing an issue down the line I’ll let you know.

NOTE: I did try removing and installing older version of protobuf, and a few others suggested online, but it still didn’t allow me to get through the imports. From what I read, the version conflicts may also cause that error to pop up again when trying to train or use some model stuff.

Hey Kimone,

First of all, thanks for the quick replies!

The changes above worked, and I added “–upgrade” to the tensorflow import since errors arose on previous releases.

To make it clear, this is the final working library imports for me:

# Libraries
import tensorflow as tf
import pandas as pd
from tensorflow import keras
!pip install --upgrade tensorflow-datasets
import tensorflow_datasets as tfds
import numpy as np
import matplotlib.pyplot as plt


If anyone else runs into this issue, feel free to ping me!

Nice. Yeah, not even sure why they have tfds… looked it up from the course, and its used to import datasets, but this project downloads directly from FCC, so tfds isn’t needed… I’m guessing back in the day they used to download the data from tfds. It did get me curious and it was neat to find that tfds.list_builders() lists tons of datasets you can download, including the cats_vs_dogs one used previously. Oh well. It was a fun final project, I submitted it a few hours ago.

Same here! About to submit – it was a pain, but worth it.

Yeah, I looked at the TensorFlow Datasets Catalog, and it seems like a lot of potential data is missed without using them. I might do some side quests to update all the previous machine-learning projects to use live data, but I’ll do that when I can.

On another note, I am looking for more people to work on projects together… Not sure how busy you are, but you sound like someone who enjoys this stuff just as much as I do.

Let me know what you think,

Thanks for the offer. Getting ready to start the job search as soon as I finish up with the last course here that I have left, the Relational Database, so will focus on that, but will let you know if/when I have time for a side project.