  #!/usr/bin/env python
  # coding: utf8
  """Train a convolutional neural network text classifier on the
  IMDB dataset, using the TextCategorizer component. The dataset will be loaded
  automatically via Thinc's built-in dataset loader. The model is added to
  spacy.pipeline, and predictions are available via `doc.cats`. For more details,
  see the documentation:
  * Training: https://spacy.io/usage/training
  
  Compatible with: spaCy v2.0.0+
 
</s> remove Compatible with: spaCy v2.0.0+
 </s> add Compatible with: spaCy v3.0.0+ </s> remove import ml_datasets
 </s> add  </s> remove         # TODO: charembed does not play nicely with dim inference yet
        # docs = [Doc(Vocab(), words=["hello"])]
        # self.model.initialize(X=docs)
        self.model.initialize()
 </s> add         docs = [Doc(Vocab(), words=["hello"])]
        self.model.initialize(X=docs) </s> remove def _set_dims(model, name, value):
    # Loop through the model to set a specific dimension if its unset on any layer.
    for node in model.walk():
        if node.has_dim(name) is None:
            node.set_dim(name, value)

 </s> add 
automatically via the package `ml_datasets`. The model is added to
  #!/usr/bin/env python
  # coding: utf8
  """Train a convolutional neural network text classifier on the
  IMDB dataset, using the TextCategorizer component. The dataset will be loaded
automatically via the package `ml_datasets`. The model is added to
  spacy.pipeline, and predictions are available via `doc.cats`. For more details,
  see the documentation:
  * Training: https://spacy.io/usage/training
  
  Compatible with: spaCy v2.0.0+
keep keep keep keep replace keep keep keep keep keep
 Train textcat with config (#5143)

* bring back default build_text_classifier method

* remove _set_dims_ hack in favor of proper dim inference

* add tok2vec initialize to unit test

* small fixes

* add unit test for various textcat config settings

* logistic output layer does not have nO

* fix window_size setting

* proper fix

* fix W initialization

* Update textcat training example

* Use ml_datasets
* Convert training data to `Example` format
* Use `n_texts` to set proportionate dev size

* fix _init renaming on latest thinc

* avoid setting a non-existing dim

* update to thinc==8.0.0a2

* add BOW and CNN defaults for easy testing

* various experiments with train_textcat script, fix softmax activation in textcat bow

* allow textcat train script to work on other datasets as well

* have dataset as a parameter

* train textcat from config, with example config

* add config for training textcat

* formatting

* fix exclusive_classes

* fixing BOW for GPU

* bump thinc to 8.0.0a3 (not published yet so CI will fail)

* add in link_vectors_to_models which got deleted

Co-authored-by: Adriane Boyd <adrianeboyd@gmail.com> 
examples/training/train_textcat.py