C4, W3, A1,Autonomous_driving_application_Car_detection tensorflow error

Hello, I have a habit of running the coeds provided in assignments on my own pc. For the convolutional neural networks week 3’s assignment, we have to implement YOLOv2 algorithm for object detection. Importing the provided yolo repo to my code, runs to the following error which is also depicted in the attachment:

ModuleNotFoundError: No module named ‘keras.layers.merge’

As I gather, this error is due to the fact that this repo is so old and the assignment uses tensorflow version 2.3.0 while newest tf version is 2.12.0

Now the question that I have is that are there any solutions besides downgrading tf to 2.3.0 for running this repo in my local pc?

Thanks in advance

There are two fundamental choices to solve a “versionitis” problem like this:

  1. Construct an environment that duplicates the exact set of versions required. Not sure if Anaconda (conda) can handle versioning of TF, but it can for python packages in general.
  2. You just have to solve each version problem one at a time. What is the 2.12 way to do keras.layers.merge? There must be a way to do it, but you’ll have to figure that out from the TF /Keras documentation. So that is debugging and research of an unknown extent. Once you solve that problem, how many more landmines are there to step on and maybe some of the other ones will be more subtle and just give a wrong answer.

There is probably no way to estimate which of the above methods is more or less work in a given case. But one can say that the advantage of 1) is that once you learn how to do it, then it is a generalizable solution for other similar cases you may hit in the future. Note that not all the notebooks here use the same version of TF. That said, it is not a simple process and we have no “official” documentation for how to do that, but here’s a thread with a lot of information to get you started down that path with pip and conda.

1 Like

Thank you for your complete answer.

One additional argument for choosing @paulinpaloalto ‘s #1 choice above - build a virtual env to replicate the one the course is running - is that sometimes, and I think this autonomous vehicle exercise is an example, the programs load and (re)use a pretrained model. I have my doubts about the prospects of running a model saved under TF 2.3 in a 2.12 environment. In other words, even if you found and hand migrated specific version incompatibilities found in the code you might not achieve full success.

I also downloaded and ran the exercises from the various specializations as I took them over several years. I found best results having a few tailored environments. For example, one for the NLP course, one for the AI in Medicine course, one for Machine Learning. They don’t all require the same libraries, and keeping the environments smaller allowed me to manage and update them independently. Better in my experience than having a single huge environment that has all libraries and packages for everything I ever try to run. YMMV

PS: like the thread linked above, I used conda because it is by nature smaller than Anaconda, which by default contained a large number of pieces I didn’t need, but not everything that I did.