# ValueError: could not broadcast input array from shape (128) into shape (96)

**URL:** <https://support.prodi.gy/t/valueerror-could-not-broadcast-input-array-from-shape-128-into-shape-96/2668>\
**Category:** Uncategorized\
**Tags:** usage, ner, spacy, solved\
**Created:** [March 17, 2020, 1:57pm UTC](https://support.prodi.gy/t/valueerror-could-not-broadcast-input-array-from-shape-128-into-shape-96/2668 "2020-03-17T13:57:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prabakaran](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@Prabakaran](https://support.prodi.gy/u/Prabakaran)\
**Post date:** [March 17, 2020, 1:57pm UTC](https://support.prodi.gy/t/valueerror-could-not-broadcast-input-array-from-shape-128-into-shape-96/2668/1 "2020-03-17T13:57:44Z")

</div>

Hi Ines,

I'm trying to tag Entities in NEWS articles and train using prodigy. [This is just a trial/test run using prodigy, so using minimum number of example]

I have used below command  
" **prodigy ner.manual ner\_v12 en\_core\_web\_sm prodigy\_format\_ner\_input\_v12\_sample.jsonl --label Role,Department**"

This worked for me in tagging.

Then i was trying to use "Train" via prodigy using the below command:  
" **prodigy train ner ner\_v12 en\_core\_web\_sm --init-tok2vec ./tok2vec\_cd8\_model289.bin --output ./tmp\_model --eval-split 0.2**"

I'm getting an error as:

Loaded model 'en\_core\_web\_sm'  
Created and merged data for 489 total examples  
Using 392 train / 97 eval (split 20%)  
Component: ner | Batch size: compounding | Dropout: 0.2 | Iterations: 10  
✔ Initializing with tok2vec weights ./tok2vec\_cd8\_model289.bin

Traceback (most recent call last):  
File "/home/merit/anaconda3/envs/prodigy/lib/python3.7/runpy.py", line 193, in \_run\_module\_as\_main  
" **main**", mod\_spec)  
File "/home/merit/anaconda3/envs/prodigy/lib/python3.7/runpy.py", line 85, in \_run\_code  
exec(code, run\_globals)  
File "/home/merit/anaconda3/envs/prodigy/lib/python3.7/site-packages/prodigy/ **main**.py", line 52, in   
controller = recipe(_args, use\_plac=True)  
File "cython\_src/prodigy/core.pyx", line 213, in prodigy.core.recipe.recipe\_decorator.recipe\_proxy  
File "/home/merit/anaconda3/envs/prodigy/lib/python3.7/site-packages/plac\_core.py", line 328, in call  
cmd, result = parser.consume(arglist)  
File "/home/merit/anaconda3/envs/prodigy/lib/python3.7/site-packages/plac\_core.py", line 207, in consume  
return cmd, self.func(_(args + varargs + extraopts), \*\*kwargs)  
File "/home/merit/anaconda3/envs/prodigy/lib/python3.7/site-packages/prodigy/recipes/train.py", line 130, in train  
load\_pretrained\_tok2vec(pipe, init\_tok2vec, require=True)  
File "cython\_src/prodigy/util.pyx", line 520, in prodigy.util.load\_pretrained\_tok2vec  
File "/home/merit/anaconda3/envs/prodigy/lib/python3.7/site-packages/thinc/neural/\_classes/model.py", line 376, in from\_bytes  
copy\_array(dest, param[b"value"])  
File "/home/merit/anaconda3/envs/prodigy/lib/python3.7/site-packages/thinc/neural/util.py", line 145, in copy\_array  
dst[:] = src  
ValueError: could not broadcast input array from shape (128) into shape (96)

Please let me know how to proceed further!

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [March 17, 2020, 2:08pm UTC](https://support.prodi.gy/t/valueerror-could-not-broadcast-input-array-from-shape-128-into-shape-96/2668/2 "2020-03-17T14:08:40Z")

</div>

The problem here is that the base model doesn't match: if you're using tok2vec weights trained with vectors, you also need to use those vectors as the base model during training. The `tok2vec_cd8_model289.bin` weights were pretrained using the `en_vectors_web_lg` package, so this should be the base model for training (not `en_core_web_sm`, which has no vectors at all).

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [March 18, 2020, 9:39am UTC](https://support.prodi.gy/t/valueerror-could-not-broadcast-input-array-from-shape-128-into-shape-96/2668/4 "2020-03-18T09:39:52Z")

</div>

> [@Prabakaran](#):
>
> **prodigy train ner ner\_v12 en\_core\_web\_lg --init-tok2vec ./tok2vec\_cd8\_model289.bin --output ./tmp\_model --eval-split 0.2**

You want the `en_vectors_web_lg`, which are the large word vectors (not the core model trained with a subset of those vectors).

---

<div class="post-metadata">

**Author:** ![rhayderc](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/rhayderc/32/937_2.png) [@rhayderc](https://support.prodi.gy/u/rhayderc)\
**Post date:** [May 23, 2020, 8:18am UTC](https://support.prodi.gy/t/valueerror-could-not-broadcast-input-array-from-shape-128-into-shape-96/2668/6 "2020-05-23T08:18:09Z")

</div>

Hi @ines,

I was following along the`ner-food-ingredients` tutorial. Installed `prodigy` and `en_core_web_lg` using the following commands in a virtual environment.

```python
python -m pip install ./models/prodigy-1.9.9-cp36.cp37.cp38-cp36m.cp37m.cp38-macosx_10_13_x86_64.whl

python -m spacy download en_core_web_lg 

```

## Command

I came across the same issue when running the following command:

```python
prodigy train ner food_data en_core_web_lg --init-tok2vec ./models/tok2vec_cd8_model289.bin --output ./models/tmp_model --eval-split 0.2

```

## Output

```python
Traceback (most recent call last):
  File "/Users/raqib/.pyenv/versions/3.7.0/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    " __main__", mod_spec)
  File "/Users/raqib/.pyenv/versions/3.7.0/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/raqib/nlp/ner-food-ingredients/.venv/lib/python3.7/site-packages/prodigy/ __main__.py", line 60, in <module>
    controller = recipe(*args, use_plac=True)
  File "cython_src/prodigy/core.pyx", line 213, in prodigy.core.recipe.recipe_decorator.recipe_proxy
  File "/Users/raqib/nlp/ner-food-ingredients/.venv/lib/python3.7/site-packages/plac_core.py", line 367, in call
    cmd, result = parser.consume(arglist)
  File "/Users/raqib/nlp/ner-food-ingredients/.venv/lib/python3.7/site-packages/plac_core.py", line 232, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/Users/raqib/nlp/ner-food-ingredients/.venv/lib/python3.7/site-packages/prodigy/recipes/train.py", line 139, in train
    load_pretrained_tok2vec(pipe, init_tok2vec, require=True)
  File "cython_src/prodigy/util.pyx", line 520, in prodigy.util.load_pretrained_tok2vec
  File "/Users/raqib/nlp/ner-food-ingredients/.venv/lib/python3.7/site-packages/thinc/neural/_classes/model.py", line 396, in from_bytes
    copy_array(dest, param[b"value"])
  File "/Users/raqib/nlp/ner-food-ingredients/.venv/lib/python3.7/site-packages/thinc/neural/util.py", line 145, in copy_array
    dst[:] = src
ValueError: could not broadcast input array from shape (128) into shape (96)

```

## Other details

```python
pip show spacy
Name: spacy
Version: 2.2.4
Location: /Users/raqib/nlp/ner-food-ingredients/.venv/lib/python3.8/site-packages
Required-by: prodigy, en-core-web-lg

```

```python
pip show en-core-web-lg
Name: en-core-web-lg
Version: 2.2.0
Location: /Users/raqib/nlp/ner-food-ingredients/.venv/lib/python3.8/site-packages
Requires: spacy

```

```python
pip show prodigy
Name: prodigy
Version: 1.9.9
Location: /Users/raqib/nlp/ner-food-ingredients/.venv/lib/python3.8/site-packages

```

## What have I tried thus far:

1. Tried version `2.2.5` and `2.2.0` of `en-core-web-lg`
2. Tried changing python version from `3.8` to `3.7`.

Would appreciate any pointers.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [May 25, 2020, 11:07am UTC](https://support.prodi.gy/t/valueerror-could-not-broadcast-input-array-from-shape-128-into-shape-96/2668/7 "2020-05-25T11:07:07Z")

</div>

@rhayderc It looks like the problem here is that the tok2vec weights you're using are incompatible with the vectors model? The tok2vec weights were trained using the `en_vectors_web_lg` vectors pack, not the core model with a smaller set of vectors. So if you use `en_vectors_web_lg` instead, it should work – that's also what I'm using in my food tutorial 🙂
