# Sequence Models: Week 1 assignment: Dinosaur Island

**URL:** <https://community.deeplearning.ai/t/sequence-models-week-1-assignment-dinosaur-island/550321>\
**Category:** Sequence Models\
**Tags:** week-module-1, coursera-platform\
**Created:** [January 21, 2024, 5:11am UTC](https://community.deeplearning.ai/t/sequence-models-week-1-assignment-dinosaur-island/550321 "2024-01-21T05:11:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marian\_Bartlett](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@Marian\_Bartlett](https://community.deeplearning.ai/u/Marian_Bartlett)\
**Post date:** [January 21, 2024, 5:11am UTC](https://community.deeplearning.ai/t/sequence-models-week-1-assignment-dinosaur-island/550321/1 "2024-01-21T05:11:51Z")

</div>

Hi, Could someone help with the ‘Sample()’ function for Dinosaur Island? My first output in the list of indices is correct, but the rest are wrong. I suspect it has to do with the hints about ‘ravel’ and/or ‘append’. I have read the hints but dont see how to incorporate the hints in the code.

Below is what I have for Step 3:

```
    # Step 3: Sample the index of a character within the vocabulary from the probability distribution y
    # (see additional hints above)
    idx = np.random.choice(range(len(y[:,counter])), p = y[:,counter])

    # Append the index to "indices"
    indices.append(idx)

```

---

<div class="post-metadata">

**Author:** ![Marian\_Bartlett](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@Marian\_Bartlett](https://community.deeplearning.ai/u/Marian_Bartlett)\
**Post date:** [January 21, 2024, 5:57am UTC](https://community.deeplearning.ai/t/sequence-models-week-1-assignment-dinosaur-island/550321/2 "2024-01-21T05:57:27Z")

</div>

I figured out the problem. I had initialized x and a\_prev to row vectors instead of columns. This caused my y to be the wrong shape (27x100 instead of 27x1)

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [January 21, 2024, 6:19am UTC](https://community.deeplearning.ai/t/sequence-models-week-1-assignment-dinosaur-island/550321/3 "2024-01-21T06:19:26Z")

</div>

That’s great that you were able to find the solution under your own power. Nice work!
