Create_training_example at Trigger_word_detection_v2a cannot pass with unit-tests

Hey there,

I am sure I have done with right codes, however, there is still error as output from unit-test:

AssertionError: Spectrogram is wrong. Check the parameters passed to the insert_audio_clip function

What strange is that the insert_audio_clip was passed by the its unit-tests.

Can you check once?


The exact same thing is happening to me. I hope someone knows how to get around this

I finished the assignment and submitted it despite the one test case supposedly failing. I passed with 100/100 so I guess this is not a problem for the grader

1 Like

Perhaps there is an error in your create_training_example() code that was not detected by the unit test.

If the unit test says your spectrogram of x is incorrect, you probably should believe it.

@zer2 I had the same outcome. So I submitted the homework and it could pass through 100% :man_shrugging:, although the error happened reiteratedly.
@TMosh I doubt very much that there may be problems with some functions called by create_training_example, but they pass through their unit-tests. What I mean is that the problem may not be with create_training_example itself.

Maybe the @deeplearning team should take a look at this homework and co.


1 Like

Passing the unit tests does not prove your code is 100% perfect.

For example, the unit tests do not catch all errors in the Segment Time returned by the insert_audio_clip() function.

What are some common pitfalls in the insert_audio_clip?

In step 1: not using get_random_time_segment().
In step 2: not using “is_overlapping()” in the “while” loop test clause.
In step 3: not using the “append()” method.

Exactly same problem. I ignore it and the final grader gives me 100/100

Hours searching for a problem. I guess is a random seed issue.

Another cause for these types of problems is if you re-run only individual cells. The assignments use a lot of global variables, and it’s very easy to get them into invalid states.

Restarting the kernel and re-running all of the cells should be in your kit of tools whenever you get an unexpected error.

If you have downloaded the notebook and run locally, the UNIT TEST may fail, because it’s likely that backgrounds[idx] in your local folder ≠ backgrounds[index] in Coursera site folder, activates[idx] ≠ activates[idx], negatives[idx] ≠ negatives[idx] etc… You can check it by listening to the .wav files or checking for the len(activates[idx]) etc… For instance:

activates, negatives, backgrounds = load_raw_audio(’./raw_data/’)

print(“len(backgrounds) =”, len(backgrounds))
for idx in range(len(backgrounds)):
# print(“idx =”, idx)
print(“backgrounds[”, str(idx),"]", " len =" + str(len(backgrounds[idx])))

print(“len(activates) =”, len(activates))
for idx in range(len(activates)):
# print(“idx =”, idx)
print(“activates[”, str(idx),"]", " len =" + str(len(activates[idx])))

print(“len(negatives) =”, len(negatives))
for idx in range(len(negatives)):
# print(“idx =”, idx)
print(“negatives[”, str(idx),"]", " len =" + str(len(negatives[idx])))

NOTE!! even though the len are same, it is likely that backgrounds[0] in your local folder ≠ backgrounds[0] in Coursera site folder!!!

I hope this helps.

I had the same problem but the final grader returned 0/100.
I solved this by initialising the segment_time variable in the create_training_example function and then using it in both calls to insert_audio_clip.

Hope this helps!

@Nuno_Rodrigues, I don’t think that’s either correct or necessary.

@Nuno_Rodrigues if you send me your notebook file (via a private message), I’d like to look into it.

Thanks for your help.
Attached is a zipped version of the notebook (please note that in order to be able to attach the file I had to keep the ipynb extension).
{moderator edit: deleted attachment}

FYI, to use a private message, you click on a name and select the “Message” button.
Posting your code on the forum is not allowed.
I’ll review it and provide feedback.

Please send me your notebook file again - but not as a zip file (I can’t open it due to security policies).

Just download the ipynb file and upload it via a private message.