RASA Training Model

Hi ,

I am trying to do below code but facing an error while execution.

Not able to fix it. Please help

Code -

import asyncio

fallback = FallbackPolicy(fallback_action_name=“utter_unclear”, core_threshold=0.2, nlu_threshold=0.5)

agent = Agent(‘domain_ad.yml’, policies=[MemoizationPolicy(max_history=2), KerasPolicy(epochs=500, batch_size=10)])

loading our neatly defined training dialogues

training_data = agent.load_data(‘stories_ad.md’)

loop = asyncio.get_event_loop()

loop.stop()

loop.close()

training_data = loop.run_until_complete(agent.load_data(‘stories_ad.md’)) agent.train(training_data)

loop.close()

agent.train( training_data, validation_split=0.0 )

agent.persist(‘models/nlu/helpdesk’)

Issue-

RuntimeError: This event loop is already running

Processed Story Blocks: 100%|█████████████████████████████████████████████| 8/8 [00:00<00:00, 640.95it/s, # trackers=1] Processed Story Blocks: 100%|█████████████████████████████████████████████| 8/8 [00:00<00:00, 617.07it/s, # trackers=8] Processed Story Blocks: 100%|████████████████████████████████████████████| 8/8 [00:00<00:00, 135.93it/s, # trackers=50] Processed Story Blocks: 100%|████████████████████████████████████████████| 8/8 [00:00<00:00, 138.29it/s, # trackers=50]

Can Anyone tell me why this is coming and what i have to do stop it ?

Because of this issue my model is not getting saved in the model directory.

RASA version -1.7.0

Hi @Aditya07! Can you please share your config and stories? Out of curiosity, why did you write this code instead of just using the Rasa CLI?

Sure I will share.

I am using Jupyter NB to make my chatbot. Would you share how to use CLI and also how i can use RASA with Jupyter NB.

I am new to RASA so not know lot of things

stories_ad.md (508 Bytes) config_adi.yml (446 Bytes)

One more issue now - After completing 500 epochs , Python throws the below error. I have no clue how to solve this.

@tyd Please help

from rasa.core.policies.fallback import FallbackPolicy

from rasa.core.policies.keras_policy import KerasPolicy

from rasa.core.policies.memoization import MemoizationPolicy

from rasa.core.agent import Agent

import asyncio

fallback = FallbackPolicy(fallback_action_name = “utter_unclear”,

core_threshold = 0.2,

nlu_threshold = 0.5)

agent = Agent(‘domain_ad.yml’, policies = [MemoizationPolicy(max_history = 2),

KerasPolicy(epochs = 500, batch_size = 10)])

# loading our neatly defined training dialogues

# training_data = agent.load_data(‘stories_ad.md’)

loop = asyncio.get_event_loop()

# loop.stop()

# loop.close()

training_data = loop.run_until_complete(agent.load_data(‘stories_ad.md’))

agent.train(training_data)

# loop.close()

agent.train(

training_data,

validation_split = 0.0

)

agent.persist(‘models/nlu/helpdesk’)

Issue –

---------------------------------------------------------------------------

ValueError Traceback (most recent call last)

~.conda\envs\python-cvcourse\lib\site-packages\tensorflow_core\python\client\session.py in _run (self, handle, fetches, feed_dict, options, run_metadata)

1119 subfeed_t = self.graph.as_graph_element(

-> 1120 subfeed, allow_tensor=True, allow_operation=False)

1121 except Exception as e :

~.conda\envs\python-cvcourse\lib\site-packages\tensorflow_core\python\framework\ops.py in as_graph_element (self, obj, allow_tensor, allow_operation)

3606 with self . _lock :

-> 3607 return self . _as_graph_element_locked ( obj , allow_tensor , allow_operation )

3608

~.conda\envs\python-cvcourse\lib\site-packages\tensorflow_core\python\framework\ops.py in _as_graph_element_locked (self, obj, allow_tensor, allow_operation)

3685 if obj . graph is not self :

-> 3686 raise ValueError ( “Tensor %s is not an element of this graph.” % obj )

3687 return obj

ValueError : Tensor Tensor(“Placeholder:0”, shape=(), dtype=float32) is not an element of this graph.

During handling of the above exception, another exception occurred:

Please consider the environment before printing.

@Aditya07 The best way to train is to use the CLI (e.g. rasa train). Where did you find this code?

Sure Thanks will try CLI

Code was found from one of github repo