# ValueError: Attempt to change dimension 'nI' for model 'maxout'

**URL:** <https://support.prodi.gy/t/valueerror-attempt-to-change-dimension-ni-for-model-maxout/4874>\
**Category:** Uncategorized\
**Tags:** usage, spacy, solved\
**Created:** [October 31, 2021, 5:51am UTC](https://support.prodi.gy/t/valueerror-attempt-to-change-dimension-ni-for-model-maxout/4874 "2021-10-31T05:51:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yihzhang-suncor](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/yihzhang-suncor/32/2451_2.png) [@yihzhang-suncor](https://support.prodi.gy/u/yihzhang-suncor)\
**Post date:** [October 31, 2021, 5:51am UTC](https://support.prodi.gy/t/valueerror-attempt-to-change-dimension-ni-for-model-maxout/4874/1 "2021-10-31T05:51:57Z")

</div>

With pretrained vectors from fasttext, I've attempted to run with the below commands:

python -m spacy init vectors en my\_vectors.txt ./my\_vector\_dir  
python -m prodigy data-to-spacy ./mydata --ner mydataset1,mydataset2,mydataset3  
python -m spacy train ./mydata/config.cfg --paths.train ./mydata/train.spacy --paths.dev ./data/dev.spacy

Excerpt from my config.cfg file below, these are where I made an edit to use the custom vectors:  
[components.tok2vec.model.embed]  
@architectures = "spacy.MultiHashEmbed.v2"  
width = 128  
attrs = ["NORM","PREFIX","SUFFIX","SHAPE"]  
rows = [5000,2500,2500,2500]  
include\_static\_vectors = true

[initialize]  
vectors = "my\_vector\_dir"

Running all of the above I get this error when trying to train a spacy ner model:

=========================== Initializing pipeline ===========================  
[2021-10-30 23:35:46,534] [INFO] Set up nlp object from config  
[2021-10-30 23:35:46,545] [INFO] Pipeline: ['tok2vec', 'ner']  
[2021-10-30 23:35:46,551] [INFO] Created vocabulary  
[2021-10-30 23:35:46,832] [INFO] Added vectors: my\_vector\_dir  
[2021-10-30 23:35:46,992] [INFO] Finished initializing nlp object  
ValueError: Attempt to change dimension 'nI' for model 'maxout' from 288 to 384

Please let me know if there are any available resources or if I missed something here, thanks!

---

<div class="post-metadata">

**Author:** ![SofieVL](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/sofievl/32/915_2.png) [@SofieVL](https://support.prodi.gy/u/SofieVL)\
**Post date:** [November 2, 2021, 2:20pm UTC](https://support.prodi.gy/t/valueerror-attempt-to-change-dimension-ni-for-model-maxout/4874/2 "2021-11-02T14:20:20Z")

</div>

Hi!

You wrote that you manually made these edits:

```python
[components.tok2vec.model.embed]
@architectures = "spacy.MultiHashEmbed.v2"
width = 128
attrs = ["NORM","PREFIX","SUFFIX","SHAPE"]
rows = [5000,2500,2500,2500]
include_static_vectors = true

[initialize]
vectors = "my_vector_dir"

```

I'm not sure why you changed the setting for `width` there, but can you change it back to

```python
width = ${components.tok2vec.model.encode.width}

```

and try again?

Also, alternatively, it should be possible to give the vector model to `data-to-spacy`:

```python
python -m prodigy data-to-spacy ./mydata --ner mydataset1,mydataset2,mydataset3 -m my_vector_dir

```

and that should avoid the need to do any manual edits except for putting `include_static_vectors` to `true`.

---

<div class="post-metadata">

**Author:** ![yihzhang-suncor](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/yihzhang-suncor/32/2451_2.png) [@yihzhang-suncor](https://support.prodi.gy/u/yihzhang-suncor)\
**Post date:** [November 2, 2021, 3:07pm UTC](https://support.prodi.gy/t/valueerror-attempt-to-change-dimension-ni-for-model-maxout/4874/3 "2021-11-02T15:07:12Z")

</div>

Thank you very much, adding the parameter for the vector model directory directly in the command "python -m prodigy..." was the fix, I shouldn't have manually changed the config file afterwards.

---

<div class="post-metadata">

**Author:** ![SofieVL](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/sofievl/32/915_2.png) [@SofieVL](https://support.prodi.gy/u/SofieVL)\
**Post date:** [November 2, 2021, 3:13pm UTC](https://support.prodi.gy/t/valueerror-attempt-to-change-dimension-ni-for-model-maxout/4874/4 "2021-11-02T15:13:18Z")

</div>

Happy to hear it's working now!
