C4W3_Assignment week 3

When creating a post, please add:

The error message from the grader is pretty explicit. Have you searched the notebook for the string example_jsons? The theory is that your code is not general: it passes one test in the notebook, but fails a different test from the grader. Is there anything about the way your code handles that variable name that might fail in a different test case? E.g. are you referencing global variables directly from the local scope of your function, as opposed to referencing them through the formal parameters of the function?

You can see my complete answer, but the debugger is not responding. Sorry, but the debugger in this version Natural Language Processing faces many problems that I could not solve because they are technical problems, and I did not find anyone from technical support. I speak with courseraThey say we do not have the authority to fix errors. If they do not have the authority, why do they offer the course?

Hi @Alaa_Player

I have not had the chance to complete this week’s Assignment, but as Paul mentioned the grader tells you that it’s missing example_jsons variable.

So make sure that you have it in your prior cells (no typos, no deleted cells, no deleted files (since grader should be loading it from the path) etc.).

Do you get the last screen shot from the example_jsons variable?

Basically, it is one of the paragraphs that I cannot edit

I also have not gotten to this assignment. In terms of getting help, you need to understand the role of the different players here:

Coursera is just the “platform”. They do not create the courses, so they can only help you with things about the framework or platform, e.g. your Coursera account and billing and things like that. They will also know if there is a problem with their servers in general, but the point is that they know nothing about the actual contents of any of the various courses.

The courses are provided by other companies and universities, using Coursera’s tools and platform. These particular courses are provided by DeepLearning.AI, which is a completely separate company from Coursera, even though Andrew Ng is Chairman of the Board of both companies. The DLAI staff are the ones who know the contents of the courses. Now when they build a course and present it, they are using Coursera APIs and back end services. So maybe a grader problem could be caused by the DeepLearning folks not using a Coursera API in the correct way. But even there, you need to talk to DeepLearning.AI about that.

Then the next level is the economics of this whole space. DeepLearning.AI is not making that much money from each student, something like $50/month, but they split that with Coursera, so I don’t actually know how much they get. So call it $25/month. Now think about what the salary of an engineer or customer support person is. I don’t know current pay scales, but I am sure that it’s a lot more than $25/hour, particularly if you consider the full “burdened cost” of an employee (meaning including all the benefits the employer is providing like health insurance, a building to work in that requires heat and electricity and insurance coverage, HR support services, training, snacks and coffee and so forth). So they really can’t afford to have every question on the forum take half an hour of some engineer’s time to answer and solve. Besides those people are busy creating new courses. So that means the support and question answering gets left mostly to the community, including the mentors. We are just fellow students who do not get paid to do this. We also have no visibility into things like how the graders are actually implemented. So we have to try to answer things based on our own programming experience and using the courses ourselves and trying to guess what is going on based on that.

Ok, back to your problem. That cell looks pretty straightforward. So now you need to think more deeply: why would that work when you run it, but not when the grader runs it? I can think of two possible theories, but that’s just the limit of my imagination:

  1. The “open” of that file fails in the grader environment for some reason. If that’s what is happening, then that probably would be a problem with the course and would require help from the course staff.
  2. There is some cell earlier in the notebook that is throwing an exception before the execution even gets to the cell that loads that file. That would be because of the type of “non-generality” problem that I mentioned earlier. Meaning some way in which your code is specific to the notebook context and fails when the grader runs it. E.g. referencing global variables and the like.

So please have a careful look at the notebook before that cell. How many code cells are there before that one? Are there any in which you had to write code?

Do you want me to send you the entire notebook so that you can verify that all of my answers are correct, but there is a defect in the automatic corrector?

We can try that, but as I mentioned I have not taken that course and am not a mentor for it, so I am probably not the person you need to look at. I will send you a DM message about how to share the notebook with me.

I think the real solution is that I will try to get in touch with the course staff. They have recently updated these courses and maybe there are still bugs in them.

Thank you for your help

Notice that there are two different cells that define example_jsons that I see in a clean notebook. Here’s the other one with a different pathname:

# Load example jsons
with open('data/c4-en-10k.jsonl', 'r') as file:
    example_jsons = [json.loads(line.strip()) for line in file]

# Printing the examples to see how the data looks like
for i in range(5):
    print(f'example number {i+1}: \n\n{example_jsons[i]} \n')
1 Like

Just to close the loop on the public thread, the bug is exactly what I suggested in my first response on this thread:

Within the function parse_squad, the code directly references the global variable example_jsons. That happens to be what is passed as the argument by the test case in the notebook, so it works there. But the code is wrong: it is not general. The grader passes a different variable as the dataset and that test fails.

This is not a bug in the grader.

Also you modified the comments in the following cell:

# Updated answer_question function
def answer_question(question, model, tokenizer, encoder_maxlen=150, decoder_maxlen=50):
    A function for question answering using the transformer model

In a clean notebook, it looks like this:

# GRADED FUNCTION: answer_question
def answer_question(question, model, tokenizer, encoder_maxlen=150, decoder_maxlen=50):
    A function for question answering using the transformer model

Why did you do that? It turns out that you are lucky and in this case the grader doesn’t care. But there are other graders that would fail because of not finding that special comment that marks the cell as a graded function. In general, it’s not a good idea to modify things outside the “YOUR CODE HERE” segments. It’s not illegal as a general matter, but you need to be careful and make sure you know what you are doing when you “go there”. :scream_cat:

1 Like

Also note that you fail the unit test in the notebook for tokenize_and_mask and also fail the grader for that function, although the grader gives you a lot of partial credit even though it shows quite a few error messages.

Help to correct the last week exercise of last course. NLP with attention models.

Please give us more information about the nature of your problem. Please realize we cannot directly see your notebooks or your work or your grades, so you need to show us the error that you are getting.

1 Like

This is the first error i am facing, the expected shape should 19 but my programming returning 18.

Hi @m_hassan

You’re clearly missing the EOS token. Your mistake is probably at the last line of the function (you probably forgot to replace the None value):
# Add EOS token to the end of the targets


1 Like

Here is my code snippet.

Here is the error message.

Hello @m_hassan

You using an obsolete copy of assignment hence encountering these issue. the code line raising the issue in your code snipped is not present in the updated assignment. So kindly get a fresh copy and then re-do the assignment.

In case you state that you have an update copy then either you have edited the grader cell as some of the arguments are deleted and code lines are added by you which I am not sure.

So it is better you grab a fresh copy of assignment and start from scratch.

to get a fresh copy, follow the steps in the below post link

Also please avoid posting codes on public post threads, it is against community guidelines. When a mentor asks you for your codes, then you can personal DM them, otherwise it is always a better practice to share a screenshot of your error, and/or your output with the expected output without sharing any graded codes to prevent action from community staff for your membership on discourse community.


1 Like