C5W3 - Trigger Word Detection - Code Does not Compile

Hi guys,

I get an error whenever create_training_examples is called and the grader cannot compile my notebook.

The error: Cell #24 Can’t compile student’s code. Error: ValueError(‘low >= high’)

However the error points to get_random_time_segment, which is not implemented by us.

I have not added or removed any cells, nor commented out any of the original code. Never had a problem since C1W1. I tried get the last version of the assignment and rebooted the server, but it is not working. The unit tests for insert_audio_clip are all passed

I would appreciate any help as this is delaying my progress in the course.

Here is the traceback:

ValueError Traceback (most recent call last)
in
17 print(“\033[92m All tests passed!”)
18
—> 19 create_training_example_test(create_training_example)

in create_training_example_test(target)
2 def create_training_example_test(target):
3 np.random.seed(18)
----> 4 x, y = target(backgrounds[0], activates, negatives, 1375)
5
6 assert type(x) == np.ndarray, “Wrong type for x”

in create_training_example(background, activates, negatives, Ty)
37 for random_activate in random_activates: # @KEEP
38 # Insert the audio clip on the background
—> 39 background, segment_time = insert_audio_clip(background, audio_clip, random_activate)
40 # Retrieve segment_start and segment_end from segment_time
41 segment_start, segment_end = segment_time

in insert_audio_clip(background, audio_clip, previous_segments)
22 # Step 1: Use one of the helper functions to pick a random time segment onto which to insert
23 # the new audio clip. (≈ 1 line)
—> 24 segment_time = get_random_time_segment(segment_ms)
25
26 # Step 2: Check if the new segment_time overlaps with one of the previous_segments. If so, keep

in get_random_time_segment(segment_ms)
10 “”"
11
—> 12 segment_start = np.random.randint(low=0, high=10000-segment_ms) # Make sure segment doesn’t run past the 10sec background
13 segment_end = segment_start + segment_ms - 1
14

mtrand.pyx in numpy.random.mtrand.RandomState.randint()

_bounded_integers.pyx in numpy.random._bounded_integers._rand_int64()

ValueError: low >= high

In create_training_example() at line 39, two of the arguments you’re passing to insert_audio_clip() are not correct.

One is the correct parameter and in the correct position.
One is the correct parameter but in the wrong position.
One of the parameters is wrong.
One of the correct parameters is missing entirely.

Did the tests for create_training_example() pass?

Yes, you are correct.

I fixed the parameters for create_training_example().

Restarted and Ran all cells. Passed all tests.

Just submitted and got 100/100 points.

Thanks for your help, @TMosh !

Hi I get a similar error can you plse help:

TypeError Traceback (most recent call last)
in
17 print(“\033[92m All tests passed!”)
18
—> 19 create_training_example_test(create_training_example)

in create_training_example_test(target)
2 def create_training_example_test(target):
3 np.random.seed(18)
----> 4 x, y = target(backgrounds[0], activates, negatives, 1375)
5
6 assert type(x) == np.ndarray, “Wrong type for x”

in create_training_example(background, activates, negatives, Ty)
39 background, segment_time = insert_audio_clip(background, random_activate, previous_segments)
40 # Retrieve segment_start and segment_end from segment_time
—> 41 segment_start, segment_end = get_random_time_segment(segment_time)
42 # Insert labels in “y” at segment_end
43 y = insert_ones(y, segment_end)

in get_random_time_segment(segment_ms)
10 “”"
11
—> 12 segment_start = np.random.randint(low=0, high=10000-segment_ms) # Make sure segment doesn’t run past the 10sec background
13 segment_end = segment_start + segment_ms - 1
14

TypeError: unsupported operand type(s) for -: ‘int’ and ‘tuple’

I also have similar error. Have you solved it?

get_random_time segment takes an int and return a tuple

you are inserting a tuple. check if you already have a tuple that you can reference in your code