# RASA Training Model

**URL:** <https://forum.rasa.com/t/rasa-training-model/24360>\
**Category:** Rasa Open Source\
**Created:** [February 5, 2020, 4:10am UTC](https://forum.rasa.com/t/rasa-training-model/24360 "2020-02-05T04:10:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya07](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@Aditya07](https://forum.rasa.com/u/Aditya07)\
**Post date:** [February 5, 2020, 4:10am UTC](https://forum.rasa.com/t/rasa-training-model/24360/1 "2020-02-05T04:10:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tyd](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tyd/32/3030_2.png) [@tyd](https://forum.rasa.com/u/tyd)\
**Post date:** [February 11, 2020, 1:01am UTC](https://forum.rasa.com/t/rasa-training-model/24360/2 "2020-02-11T01:01:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Aditya07](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@Aditya07](https://forum.rasa.com/u/Aditya07)\
**Post date:** [February 14, 2020, 3:25am UTC](https://forum.rasa.com/t/rasa-training-model/24360/3 "2020-02-14T03:25:00Z")

</div>

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](https://forum.rasa.com/uploads/short-url/4wU4G0MxzdrQ0gKF8WNgaPpdqBc.md) (508 Bytes) [config\_adi.yml](https://forum.rasa.com/uploads/short-url/bYx4JQJSVvVsjmXwztnEdFLd2mv.yml) (446 Bytes)

---

<div class="post-metadata">

**Author:** ![Aditya07](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@Aditya07](https://forum.rasa.com/u/Aditya07)\
**Post date:** [February 14, 2020, 6:39am UTC](https://forum.rasa.com/t/rasa-training-model/24360/4 "2020-02-14T06:39:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tyd](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tyd/32/3030_2.png) [@tyd](https://forum.rasa.com/u/tyd)\
**Post date:** [February 18, 2020, 4:31pm UTC](https://forum.rasa.com/t/rasa-training-model/24360/5 "2020-02-18T16:31:35Z")

</div>

@Aditya07 The best way to train is to use the [CLI](https://rasa.com/docs/rasa/user-guide/command-line-interface) (e.g. [rasa train](https://rasa.com/docs/rasa/user-guide/command-line-interface/#train-a-model)). Where did you find this code?

---

<div class="post-metadata">

**Author:** ![Aditya07](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@Aditya07](https://forum.rasa.com/u/Aditya07)\
**Post date:** [February 19, 2020, 3:43am UTC](https://forum.rasa.com/t/rasa-training-model/24360/6 "2020-02-19T03:43:04Z")

</div>

Sure Thanks will try CLI

Code was found from one of github repo
