C4 W2 A2:Module 'tensorflow.keras.layers' has no attribute 'RandomFlip'

ai_curious,

What is the best way to build a local env to match the versions run by Coursera? Is Coursera on AWS?

Thank you.

Cindy

1 Like

Some of the more recent courses use Google Colab. At least when I was taking them (as long as 5 years ago for Deep Learning Specialization) the older ones all ran on AWS. From a Python program you can run something like…

import pip #needed to use the pip functions
for i in pip.get_installed_distributions(local_only=True):
    print(i)

to get a list of all installed packages and versions. Then use pip or conda or some other package manager to replicate it.

ai_curious,

Thank you.

Got the following error when I run this in one of my program assignments in Coursera DeepLearningAI.

import pip #needed to use the pip functions
for i in pip.get_installed_distributions(local_only=True):
print(i)

AttributeError Traceback (most recent call last)
in
1 import pip #needed to use the pip functions
----> 2 for i in pip.get_installed_distributions(local_only=True):
3 print(i)

AttributeError: module ‘pip’ has no attribute ‘get_installed_distributions’

Thank you.

Cindy

1 Like

I had that in some old code, but it looks like a pip refactor hid that function from external users. Always more than one way to do something in Python though…

     import pkg_resources
     dists = [str(d) for d in pkg_resources.working_set]
     print(dists)
1 Like

ai_curious,

Thank you so much.

This list is so comprehensive. Do we need to set up a virtual environment that match all these version requirements?
Python version is not in this list.

Print out below from the code you provided:

[‘zipp 3.1.0’, ‘zict 2.0.0’, ‘xlrd 1.2.0’, ‘wrapt 1.12.1’, ‘widgetsnbextension 3.5.1’, ‘wheel 0.34.2’, ‘Werkzeug 1.0.1’, ‘webencodings 0.5.1’, ‘wcwidth 0.1.9’, ‘vincent 0.4.4’, ‘urllib3 1.25.9’, ‘typing-extensions 3.7.4.2’, ‘traitlets 4.3.3’, ‘tqdm 4.45.0’, ‘tornado 6.0.4’, ‘toolz 0.10.0’, ‘testpath 0.4.4’, ‘terminado 0.8.3’, ‘termcolor 1.1.0’, ‘tensorflow 2.3.0’, ‘tensorflow-estimator 2.3.0’, ‘tensorboard 2.5.0’, ‘tensorboard-plugin-wit 1.8.0’, ‘tensorboard-data-server 0.6.0’, ‘tblib 1.6.0’, ‘tables 3.6.1’, ‘sympy 1.5.1’, ‘statsmodels 0.11.1’, ‘SQLAlchemy 1.3.16’, ‘soupsieve 1.9.4’, ‘sortedcontainers 2.1.0’, ‘six 1.14.0’, ‘setuptools 46.1.3.post20200325’, ‘Send2Trash 1.5.0’, ‘seaborn 0.10.1’, ‘scipy 1.4.1’, ‘scikit-learn 0.22.2.post1’, ‘scikit-image 0.16.2’, ‘ruamel.yaml 0.16.6’, ‘ruamel.yaml.clib 0.2.0’, ‘ruamel-yaml 0.15.80’, ‘rsa 4.0’, ‘requests 2.23.0’, ‘requests-oauthlib 1.3.0’, ‘pyzmq 19.0.0’, ‘PyYAML 5.3.1’, ‘PyWavelets 1.1.1’, ‘pytz 2020.1’, ‘python-json-logger 0.1.11’, ‘python-editor 1.0.4’, ‘python-dateutil 2.8.1’, ‘PySocks 1.7.1’, ‘pyrsistent 0.16.0’, ‘pyparsing 2.4.7’, ‘pyOpenSSL 19.1.0’, ‘PyJWT 1.7.1’, ‘Pygments 2.6.1’, ‘pydot 1.2.3’, ‘pycurl 7.43.0.5’, ‘pycparser 2.20’, ‘pycosat 0.6.3’, ‘pyasn1 0.4.8’, ‘pyasn1-modules 0.2.8’, ‘ptyprocess 0.6.0’, ‘psutil 5.7.0’, ‘protobuf 3.11.4’, ‘prompt-toolkit 3.0.5’, ‘prometheus-client 0.7.1’, ‘pip 20.1’, ‘Pillow 7.1.2’, ‘pickleshare 0.7.5’, ‘pexpect 4.8.0’, ‘patsy 0.5.1’, ‘partd 1.1.0’, ‘parso 0.7.0’, ‘pandocfilters 1.4.2’, ‘pandas 1.0.3’, ‘pamela 1.0.0’, ‘packaging 20.1’, ‘opt-einsum 3.2.1’, ‘olefile 0.46’, ‘oauthlib 3.0.1’, ‘numpy 1.18.4’, ‘numexpr 2.7.1’, ‘numba 0.48.0’, ‘notebook 6.0.3’, ‘networkx 2.4’, ‘nbformat 5.0.6’, ‘nbconvert 5.6.1’, ‘msgpack 1.0.0’, ‘mpmath 1.1.0’, ‘mock 4.0.2’, ‘mistune 0.8.4’, ‘matplotlib 3.2.1’, ‘MarkupSafe 1.1.1’, ‘Markdown 3.2.1’, ‘Mako 1.1.0’, ‘locket 0.2.0’, ‘llvmlite 0.31.0’, ‘kiwisolver 1.2.0’, ‘Keras-Preprocessing 1.1.2’, ‘Keras-Applications 1.0.8’, ‘jupyterlab 2.1.1’, ‘jupyterlab-server 1.1.1’, ‘jupyterhub 1.1.0’, ‘jupyter-telemetry 0.0.5’, ‘jupyter-core 4.6.3’, ‘jupyter-client 6.1.3’, ‘jsonschema 3.2.0’, ‘json5 0.9.0’, ‘joblib 0.14.1’, ‘Jinja2 2.11.2’, ‘jedi 0.17.0’, ‘ipywidgets 7.5.1’, ‘ipython 7.14.0’, ‘ipython-genutils 0.2.0’, ‘ipympl 0.5.6’, ‘ipykernel 5.2.1’, ‘importlib-metadata 1.6.0’, ‘imageio 2.8.0’, ‘idna 2.9’, ‘HeapDict 1.0.1’, ‘h5py 2.10.0’, ‘grpcio 1.28.1’, ‘graphviz 0.16’, ‘google-pasta 0.2.0’, ‘google-auth 1.14.1’, ‘google-auth-oauthlib 0.4.1’, ‘gmpy2 2.1.0b1’, ‘gast 0.3.3’, ‘fsspec 0.7.3’, ‘fastcache 1.1.0’, ‘entrypoints 0.3’, ‘distributed 2.15.2’, ‘dill 0.3.1.1’, ‘defusedxml 0.6.0’, ‘decorator 4.4.2’, ‘dask 2.15.0’, ‘cytoolz 0.10.1’, ‘Cython 0.29.17’, ‘cycler 0.10.0’, ‘cryptography 2.9.2’, ‘conda 4.8.2’, ‘conda-package-handling 1.6.0’, ‘cloudpickle 1.4.1’, ‘click 7.1.2’, ‘chardet 3.0.4’, ‘cffi 1.14.0’, ‘certipy 0.1.3’, ‘certifi 2020.4.5.1’, ‘cachetools 4.1.0’, ‘brotlipy 0.7.0’, ‘Bottleneck 1.3.2’, ‘bokeh 2.0.1’, ‘blinker 1.4’, ‘bleach 3.1.4’, ‘beautifulsoup4 4.9.0’, ‘backcall 0.1.0’, ‘attrs 19.3.0’, ‘async-generator 1.10’, ‘astunparse 1.6.3’, ‘astor 0.8.1’, ‘alembic 1.4.2’, ‘absl-py 0.9.0’]

1 Like

The short answer is ‘no’
A better answer is ‘it depends’

Looks like there are many packages in that list that aren’t used in most of the programming exercises. seaborn is one example. jupyter-server is another.

I would start with just the list of explicit imports in the code, try to run, and install additional packages only as needed. That’s also why I used conda instead of Anaconda. conda doesn’t install nearly as much by default.

1 Like

ai_curious,

Thank you. This information really helps.

Regards,

Cindy

1 Like