C1_W4_Final_Assignment There was a problem with data included

Hello, there was a problem with this embedding dataset. When I tried to complete these part below ( test_get_document_embedding and test_get_document_vecs), it keeps announcing problem relating to this dataset.

. I tried to do everything but can not fix it

It appears the problem is that your get_document_embedding() function does not work correctly.

I say this because the function that is throwing the error is one that tests your code.

Yes, as Tom says, this is a bug in your function. Your logic is assuming that every word has an embedding in the dictionary, but that is not correct assumption. Your code needs to handle both cases: with and without an embedding for a given word.

They said this in the instructions for that function:

Document Embeddings

  • Document embedding is created by summing up the embeddings of all words in the document.
  • If we don’t know the embedding of some word, we can ignore that word.

Yes I tried to change the logic so that it could handle both cases. But it turns out incorrect result when I run final test. I will show you my result below:


And this is my fixed function:

{moderator edit - solution code removed}

It is not sufficient just to use “split()” on the tweet. You just wrote a function called process_tweet, right?

Omg right, thank you so much, I would do it again

Sorry, I was wrong: you didn’t write that function, but it is imported for you and you’ve used it before in this assignment, right?

Yes it was imported in the first code block for me. I have achieved All test passed, thank for your dedication sir!

1 Like