C3W1_Assignment_Deep_N-grams_Exercise 2 - create_batch_dataset

Hi ,
I ma getting below error ,please help me to resolve.


Hi @vemula_suman!

The error you are getting, Argument func must be a callable..., suggests that the code expects a function to be passed, but gets a generator Received ... (of type <class 'generator'>).

The problem indeed occurs because of what you are passing in the line
dataset_xy = data_generator.map(None)

You only have to pass the necessary function (to perform the mapping), there is no need in passing the generator as well. That’ s why you got this specific error.

Let me know if it was resolved or if more clarifications are needed.

PS: Please hide the first two screenshots because the solution code is visible there. The last two are ok.

Best

1 Like

hi Anna,

i have passed callable function ,split_input_target function ,but what arguments exactly should pass in the callable function

image

1 Like

The way .map functions is by applying the function you pass as an argument to all the elements of the dataset. It only needs the name of the function to work properly :slight_smile:

You can check out some more complex examples of how tf.dataset.map() operates, here:

2 Likes

hi ,
i passed only function as argument

but getting diiffrent answers


1 Like

The dataset_xy = data_generator.map(…) line is OK,

so there seems to be and some other issue, you can DM me your notebook I will take a look.

Please remove the screenshots that show your solution to dataset_xy = data_generator.map(...)

1 Like

vemula_suman, were you able to tackle this issue? I’m also facing the similar issue for create_batch_dataset. My function is able to pass the test case, but it is failing when I’m testing my function. I’m passing only the name of the function in dataset_xy = data_generator.map(…)

@ankit

although you could be having similar issue but your reason of getting this issue might be different from the learner who created the post. So it is always better to create a new topic with your issue explained briefly and more importantly sharing your output (without sharing codes) and any error encountered by taking a screenshot.

this means although your functions might be written as accord to python programming, it is not passing on test data which is most important part. Create a new post, you could always tag someone you want to ask.

Regards
DP

1 Like

I encounter the same error message like this one. @Anna_Kay @Deepti_Prasad May I ask how did you help to solve this error? Thanks.

Hi Miranda,

there are two different errors screenshoted here, which one are you getting?

You attach a screenshot, but please do not show solution code.

Thank you for getting back. I use @vemula_suman 's photo in this case. I got the same error in these two screenshots.


OK, here are some instructions according to the error the previous learner had:

In Exercise 2 - data_generator check that you are passing the input (the text) in the most appropriate format. Hint: read all of the code of the function carefully, not only the part that has to be filled. Everything that is computed is there for a reason, you have to find where to use it.

Please let me know if you were able to resolve the issue :slight_smile:

Generally speaking, the same error traceback can result from different errors, so it might be more practical to create a new post if an existing similar post does not have a satisfactory answer.

1 Like

Great hints, I got it solved :wink:

1 Like