Whats the error here in code

the code is run successfully still grader not giving marks

For the record, you’re not supposed to just post your solutions for other people to fix. Explicitly mentioned in the course honor code. But since you did, take a look at the return variable from the function. That code is supposed to build and return an ImageDataGenerator instance. What does yours return?

EDIT: upon further examination I notice that the return statement is outside of the ### START/END CODE HERE ### tags, so maybe it is part of the code provided and you didn’t write that line? (I took the class a long time ago and don’t have access to current source)

EDIT 2: for the record, here’s what I was talking about above

# A function that returns 2. * its input
def doubler(input):
    output = 2. * input
    
    return output

# A function that superficially resembles the above, but returns a reference to the function itself instead of the local computation
def doubler_func(input):
    output = 2. * input
    
    return doubler_func

    # call the first function
doubled = doubler(3.)

print(doubled)
print(type(doubled))

   #call the second function
doubler_func = doubler_func(3.)
print(doubler_func)
print(type(doubler_func))

Notice the difference in the return statements. The first one returns the computed local variable. The second one returns a reference to the function itself. Here’s the output of the print() statements

6.0
<class 'float'>

<function doubler_func at 0x16091f430>
<class 'function'>

Python will allow you to use either of these return statements; neither function causes an exception when called. It’s important, however, that what is returned from the function lines up with assumptions made by any downstream code (including unit tests and the autograder).

Hope this helps.

@Himanshu_Sharma2

You are working on a notebook that’s doesn’t look current.
Here’s the starter code in the latest version of the notebook:

# GRADED FUNCTION: image_generator
def image_generator():
    ### START CODE HERE

    # Instantiate the ImageDataGenerator class.
    # Remember to set the rescale argument.
    train_datagen = None

    # Specify the method to load images from a directory and pass in the appropriate arguments:
    # - directory: should be a relative path to the directory containing the data
    # - targe_size: set this equal to the resolution of each image (excluding the color dimension)
    # - batch_size: number of images the generator yields when asked for a next batch. Set this to 10.
    # - class_mode: How the labels are represented. Should be one of "binary", "categorical" or "sparse".
    #               Pick the one that better suits here given that the labels are going to be 1D binary labels.
    train_generator = train_datagen.flow_from_directory(directory=None,
                                                        target_size=(None, None),
                                                        batch_size=None,
                                                        class_mode=None)
    ### END CODE HERE

    return train_generator

Please get the latest version of the files for the lab by following the Refresh your Lab Workspace in this link.