# Week1 Sample function through error: parameters a and p are not the same size

**URL:** <https://community.deeplearning.ai/t/week1-sample-function-through-error-parameters-a-and-p-are-not-the-same-size/74969>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [December 14, 2021, 2:19am UTC](https://community.deeplearning.ai/t/week1-sample-function-through-error-parameters-a-and-p-are-not-the-same-size/74969 "2021-12-14T02:19:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miranda\_Lv](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Miranda\_Lv](https://community.deeplearning.ai/u/Miranda_Lv)\
**Post date:** [December 14, 2021, 2:19am UTC](https://community.deeplearning.ai/t/week1-sample-function-through-error-parameters-a-and-p-are-not-the-same-size/74969/1 "2021-12-14T02:19:52Z")

</div>

In the sample function, it throws the parameters a and p are not the same size error. I followed the suggestion from this [post](https://community.deeplearning.ai/t/dls-5-week-1-assignment-2-ex-2-choice-parameters-a-and-p-are-not-the-same-size/72157) to print the dimension of each parameter, but it seems I have the correct dimension for all parameters. Any suggestion? Thank you so much!

 ![image](https://global.discourse-cdn.com/dlai/original/2X/b/b949c4359944ddce597027f39b891532d195e4d7.png)

---

<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:** [December 14, 2021, 2:38am UTC](https://community.deeplearning.ai/t/week1-sample-function-through-error-parameters-a-and-p-are-not-the-same-size/74969/2 "2021-12-14T02:38:23Z")

</div>

Why did you subtract 1 from vocab\_size?

---

<div class="post-metadata">

**Author:** ![Miranda\_Lv](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Miranda\_Lv](https://community.deeplearning.ai/u/Miranda_Lv)\
**Post date:** [December 14, 2021, 5:33am UTC](https://community.deeplearning.ai/t/week1-sample-function-through-error-parameters-a-and-p-are-not-the-same-size/74969/3 "2021-12-14T05:33:43Z")

</div>

To get a list ranging from [0,vocab\_size-1]. Now I get what is the problem, thanks!
