Error in HomeWork 4 --> train_happy_sad_model

I don’t understand the error message

this is my code

and this is the message error


attached my assignment

[code removed - moderator]

Hey friend, if you dont mind, can you share a public Colab for a copy of your assignment, so that I can help? Or just upload it here as an attachment. :stuck_out_tongue:

For the happy or sad model, Check the shape of images. Seems to be 150150 not 300300 as described in your first Convolution layer.

As said by @Alassane_Sakande the error you are getting is due to the mismatch of the shapes
The first layer of CNN doesn’t have the same shape as the input

Ramzis_Akhmitzyanov

17m

################### C1W4 Here I preprocess the data about happy/sad:

from tensorflow.keras.preprocessing.image import ImageDataGenerator
import zipfile
from os import path, getcwd, chdir

!wget --no-check-certificate \ “https://storage.googleapis.com/laurencemoroney-blog.appspot.com/happy-or-sad.zip”
-O “/tmp/happy-or-sad.zip”

zip_ref = zipfile.ZipFile("/tmp/happy-or-sad.zip", ‘r’)
zip_ref.extractall("/tmp/h-or-s")
zip_ref.close()

GRADED FUNCTION: image_generator

def image_generator():

START CODE HERE

train_datagen = ImageDataGenerator(rescale=1/255)

 
train_generator = train_datagen.flow_from_directory(
    '/tmp/h-or-s',  
    target_size=(150, 150), 
    batch_size=10,
    class_mode='binary')

### END CODE HERE

return train_generator

####################
##################running it I got also

Proxy request sent, awaiting response… 200 OK
Length: 2670333 (2.5M) [application/zip]
Saving to: ‘/tmp/happy-or-sad.zip’

/tmp/happy-or-sad.z 100%[===================>] 2.55M --.-KB/s in 0.02s

2022-06-08 00:21:39 (139 MB/s) - ‘/tmp/happy-or-sad.zip’ saved [2670333/2670333]

########And everything else works good. Trying to submit i get 0, both part of evaluation say

!!!There was a problem compiling the code from your notebook. Details:
[Errno 2] No such file or directory: ‘/tmp/happy-or-sad.zip’ !!!

Help me, please, Mr.Mentor !

!wget --no-check-certificate https://storage.googleapis.com/laurencemoroney-blog.appspot.com/happy-or-sad.zip -O /tmp/happy-or-sad.zip

you should download the zip via :point_up: approach. There is " issue in your code.

Thank you for the kind response. For my regrets – with “ or without I still have ZERO - [Errno 2] No such file or directory: ‘/tmp/happy-or-sad.zip’

Your idea about “ is very interesting. Here is the question:

Data generator want data from /data, yes?? If so, how to realize it using old lines

zip_ref = zipfile.ZipFile("???/tmp/happy-or-sad.zip", ‘r’)

zip_ref.extractall("/tmp/h-or-s")

zip_ref.close()

to make it like

zip_ref = zipfile.ZipFile("/content/drive/My Drive/ML/tmp/happy-or-sad.zip"