Getting Warning in diet_classifier.py

I am geting this warning while training the bot here is the config that i am using:

language: en
pipeline:
- name: SpacyNLP
  model: en_core_web_md
  case_sensitive: False
- name: SpacyTokenizer
- name: RegexFeaturizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
  analyzer: word
  min_ngram: 1
  max_ngram: 4
- name: CountVectorsFeaturizer
  analyzer: char_wb
  min_ngram: 1
  max_ngram: 4
- name: DIETClassifier
  epochs: 100
policies:
- name: MemoizationPolicy
- name: TEDPolicy
  epochs: 30
- name: MappingPolicy
- name: FormPolicy
- name: TwoStageFallbackPolicy
  nlu_threshold: 0.5
  core_threshold: 0.1
  fallback_core_action_name: action_default_fallback
  fallback_nlu_action_name: action_default_fallback
  deny_suggestion_intent_name: out_of_scope

this is the warning:

/home/talha/anaconda3/envs/faq_bot/lib/python3.7/site-packages/rasa/utils/tensorflow/model_data.py:386: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray

final_data[k].append(np.concatenate(np.array(v)))

Rasa version is 1.10.5

hey @talhashaikh5, thanks for bringing this up. Could you please create an issue on GitHub for this? And please include your tensorflow and numpy versions :pray:

Go to /home/talha/anaconda3/envs/faq_bot/
Then search for model_data.py
Add dtype=object on Line 386

1 Like

this might help but then i need to make a seperate docker container for my requirements

I have the same problem. When I tried devanshamin’s solution, I get the following error when training my model:

Traceback (most recent call last): File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/eager/context.py”, line 1897, in execution_mode yield File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/data/ops/iterator_ops.py”, line 659, in _next_internal output_shapes=self._flat_output_shapes) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_dataset_ops.py”, line 2479, in iterator_get_next_sync _ops.raise_from_not_ok_status(e, name) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py”, line 6606, in raise_from_not_ok_status six.raise_from(core._status_to_exception(e.code, message), None) File “”, line 3, in raise_from tensorflow.python.framework.errors_impl.UnknownError: AttributeError: ‘int’ object has no attribute ‘ndim’ Traceback (most recent call last):

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/ops/script_ops.py”, line 236, in call ret = func(*args)

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py”, line 789, in generator_py_func values = next(generator_state.get_iterator(iterator_id))

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/utils/tensorflow/model_data.py”, line 412, in _gen_batch yield self.prepare_batch(data, start, end)

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/utils/tensorflow/model_data.py”, line 270, in prepare_batch batch_data.append(self._pad_dense_data(_data))

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/utils/tensorflow/model_data.py”, line 544, in _pad_dense_data if array_of_dense[0].ndim < 2:

AttributeError: ‘int’ object has no attribute ‘ndim’

[[{{node PyFunc}}]] [Op:IteratorGetNextSync]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/opt/anaconda3/envs/rasa_sae/bin/rasa”, line 8, in sys.exit(main()) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/main.py”, line 92, in main cmdline_arguments.func(cmdline_arguments) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/cli/train.py”, line 76, in train additional_arguments=extract_additional_arguments(args), File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/train.py”, line 50, in train additional_arguments=additional_arguments, File “uvloop/loop.pyx”, line 1456, in uvloop.loop.Loop.run_until_complete File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/train.py”, line 101, in train_async additional_arguments, File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/train.py”, line 188, in _train_async_internal additional_arguments=additional_arguments, File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/train.py”, line 245, in _do_training persist_nlu_training_data=persist_nlu_training_data, File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/train.py”, line 482, in _train_nlu_with_validated_data persist_nlu_training_data=persist_nlu_training_data, File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/nlu/train.py”, line 90, in train interpreter = trainer.train(training_data, **kwargs) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/nlu/model.py”, line 191, in train updates = component.train(working_data, self.config, **context) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/nlu/classifiers/diet_classifier.py”, line 723, in train self.component_config[BATCH_STRATEGY], File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/utils/tensorflow/models.py”, line 131, in fit ) = self._get_tf_train_functions(eager, model_data, batch_strategy) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/utils/tensorflow/models.py”, line 348, in _get_tf_train_functions train_dataset_function, self.train_on_batch, eager, “train” File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/utils/tensorflow/models.py”, line 330, in _get_tf_call_model_function tf_call_model_function(next(iter(init_dataset))) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/data/ops/iterator_ops.py”, line 630, in next return self.next() File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/data/ops/iterator_ops.py”, line 674, in next return self._next_internal() File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/data/ops/iterator_ops.py”, line 665, in _next_internal return structure.from_compatible_tensor_list(self._element_spec, ret) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/contextlib.py”, line 130, in exit self.gen.throw(type, value, traceback) File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/eager/context.py”, line 1900, in execution_mode executor_new.wait() File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/eager/executor.py”, line 67, in wait pywrap_tensorflow.TFE_ExecutorWaitForAllPendingNodes(self._handle) tensorflow.python.framework.errors_impl.UnknownError: AttributeError: ‘int’ object has no attribute ‘ndim’ Traceback (most recent call last):

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/ops/script_ops.py”, line 236, in call ret = func(*args)

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/tensorflow_core/python/data/ops/dataset_ops.py”, line 789, in generator_py_func values = next(generator_state.get_iterator(iterator_id))

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/utils/tensorflow/model_data.py”, line 412, in _gen_batch yield self.prepare_batch(data, start, end)

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/utils/tensorflow/model_data.py”, line 270, in prepare_batch batch_data.append(self._pad_dense_data(_data))

File “/opt/anaconda3/envs/rasa_sae/lib/python3.7/site-packages/rasa/utils/tensorflow/model_data.py”, line 544, in _pad_dense_data if array_of_dense[0].ndim < 2:

AttributeError: ‘int’ object has no attribute ‘ndim’

[[{{node PyFunc}}]]

Also, no model gets created.

same issue did you manage a fix?

Nope, sadly not.