Search code examples
pythontensorflowtraining-datarasa-nlurasa

module 'tensorflow' has no attribute 'set_random_seed' for RASA NLU supervised embeddings pipeline trainer


So I’m trying to train my data using supervised embeddings pipeline.

  • Rasa version: 1.10.12

  • Tensorflow version: 2.1.1

  • Rasa NLU: 0.15.1

  • config.yml contains this:

language: “en”

pipeline: “supervised_embeddings”

I’m running this on a notebook, but I keep on getting an error about tensorflow:

 from rasa_nlu.training_data import load_data

 from rasa_nlu.config import RasaNLUModelConfig

 from rasa_nlu.model import Trainer 

 from rasa_nlu import config

 #Loading DataSet 

 train_data = load_data(my_data)

 #Config Backend: Supervised embeddings 

 trainer = Trainer(config.load('drive/Colab Notebooks/config.yml'))
 
 trainer.train(train_data)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-1a55633df253> in <module>()
----> 1 trainer.train(train_data)

1 frames
/usr/local/lib/python3.6/dist-packages/rasa_nlu/classifiers/embedding_intent_classifier.py in train(self, training_data, cfg, **kwargs)
    518             # set random seed
    519             np.random.seed(self.random_seed)
--> 520             tf.set_random_seed(self.random_seed)
    521 
    522             self.a_in = tf.placeholder(tf.float32, (None, X.shape[-1]),

AttributeError: module 'tensorflow' has no attribute 'set_random_seed'

From what I found on other forums about this error type, tf.set_random_seed(self._seed) needs to be moved to tf.random.set_seed() but in this case I can't access /usr/local/lib/python3.6/dist-packages/rasa_nlu/classifiers/embedding_intent_classifier.py and change it.

Any ideas on how to fix this?

Thank you,


Solution

  • Solution: I used !pip install rasa==1.1.4 instead of !pip install rasa since supervised_embeddings pipeline has been deprecated on the newer versions of RASA.