# Improvise\_a\_Jazz\_Solo Ex 3

**URL:** <https://community.deeplearning.ai/t/improvise-a-jazz-solo-ex-3/30439>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [August 22, 2021, 9:43am UTC](https://community.deeplearning.ai/t/improvise-a-jazz-solo-ex-3/30439 "2021-08-22T09:43:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abebe](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@Abebe](https://community.deeplearning.ai/u/Abebe)\
**Post date:** [August 22, 2021, 9:43am UTC](https://community.deeplearning.ai/t/improvise-a-jazz-solo-ex-3/30439/1 "2021-08-22T09:43:35Z")

</div>

Any help i can’t figure out this  
**My code:**

```
# Step 1: Use your inference model to predict an output sequence given x_initializer, a_initializer and c_initializer.
pred = inference_model.predict([x_initializer, a_initializer, c_initializer])
# Step 2: Convert "pred" into an np.array() of indices with the maximum probabilities
indices = np.argmax(pred, axis = -1)
# Step 3: Convert indices to one-hot vectors, the shape of the results should be (Ty, n_values)
results = to_categorical(indices, num_classes=None)

```

**MY Output:**

np.argmax(results[12]) = 75  
np.argmax(results[17]) = 33  
list(indices[12:18]) = [array([75]), array([11]), array([4]), array([79]), array([18]), array([33])]

**Expected Output:**  
**np.argmax(results[12])** = 26  
**np.argmax(results[17])** =7  
**list(indices[12:18])** =[array([26]), array([18]), array([53]), array([27]), array([40]), array([7])]

**the Greader Comment**  
Code Cell UNQ\_C3: Unexpected error (ValueError('operands could not be broadcast together with shapes (13,60) (13,90) ')) occurred during function check. We expected function `predict_and_sample` to return Test 3 failed. Please check that this function is defined properly.  
If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps.  
This dependency may be the cause of the errors.

Thanks  
Abebe

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [August 22, 2021, 11:33pm UTC](https://community.deeplearning.ai/t/improvise-a-jazz-solo-ex-3/30439/2 "2021-08-22T23:33:56Z")

</div>

When you post a question, please identify the week number and assignment number, or the name of the function you’re asking about.

I’m going to assume you’re asking about the “predict\_and\_sample() function”.

In “results = …”, why does your code say that the number of classes is “None”? You can’t do classification with no classes.

---

<div class="post-metadata">

**Author:** ![Abebe](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@Abebe](https://community.deeplearning.ai/u/Abebe)\
**Post date:** [August 23, 2021, 7:52am UTC](https://community.deeplearning.ai/t/improvise-a-jazz-solo-ex-3/30439/3 "2021-08-23T07:52:28Z")

</div>

Got it. Thank you very Much.
