W4_Assignment 1 Library loading error

Hello. I tried to start the first assignment of week 4, but upon executing the very first cell I get the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-6535088a87f9> in <module>
      9 from tensorflow.keras.layers import Layer
     10 from tensorflow.keras import backend as K
---> 11 K.set_image_data_format('channelslast')
     12 import os
     13 import numpy as np

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/backend_config.py in set_image_data_format(data_format)
    147   global _IMAGE_DATA_FORMAT
    148   if data_format not in {'channels_last', 'channels_first'}:
--> 149     raise ValueError('Unknown data_format: ' + str(data_format))
    150   _IMAGE_DATA_FORMAT = str(data_format)

ValueError: Unknown data_format: channelslast

I have not modified anything, I just executed the cell as it is. I’ve tried reloading but I still get the same error. Do you know what could be the cause?

Are you running this on the course website or in some other environment (e.g. your local system)? If the latter, then you probably have a “versionitis” problem: the APIs in this space evolve pretty rapidly and (unfortunately) not always in a backwards compatible way.

PS - just to make sure, I just reran that cell in my copy of the Face Recognition Assignment on the course website and it worked with no errors for me. So I’m guessing that you must be running locally.

1 Like

I’m running it directly on the course website. Just to make sure I just reran the cell and in it still produces the same error for me.

The cell that loads all the packages should look like this:

image

Maybe you had an accidental edit.

1 Like

Eeeek! Good catch, Tom. I (obviously) didn’t look that closely at the code.

You probably didn’t do it intentionally, but you did modify that cell, as Tom points out. You must have had your cursor in the wrong place and pressed backspace at the wrong time and it removed that underscore character from the “channels_last” string.

If you want to be sure there are no other accidentally modifications, you can get a clean copy of the notebook by following the instructions on this thread. Then carefully “copy/paste” over just your completed code from the “YOUR CODE HERE” segments.

Just to make sure we weren’t seeing recent change from the course developers, I went through the exercise of getting the latest clean copy (using the above procedure) and it’s still “channels_last” with the underscore in the latest version.