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.


1 Like

hi Anna,

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


1 Like

The way .map functions, it will apply the function you pass as 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:

1 Like

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(…)


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.


1 Like