JustinaPetr / Weatherbot_Tutorial

276 stars 447 forks source link

passing `featurizer` and `max_history` to `agent.train(...)` is not supported anymore. #6

Closed dilankadias closed 6 years ago

dilankadias commented 6 years ago

I get this error when I try to run python train_init.py. Please help!!

>python train_init.py
Using TensorFlow backend.
Traceback (most recent call last):
  File "train_init.py", line 25, in <module>
    validation_split = 0.2)
  File "C:\miniconda\lib\site-packages\rasa_core\agent.py", line 243, in train
    raise Exception("Passing `featurizer` and `max_history` "
Exception: Passing `featurizer` and `max_history` to `agent.train(...)` is not supported anymore. Pass appropriate featurizer directly to the policy instead. More info https://core.rasa.com/migrations.html#x-to-0-9-0
JustinaPetr commented 6 years ago

@dilankadias I just checked my code and found that I actually left one parameter as per old version of Rasa Core, so thanks a lot for reporting this! :) . Since the release of Rasa Core v0.9.0 the parameter max_history has to be priovided directly to the policy, for example:

agent = Agent(domain_file,
              policies=[MemoizationPolicy(max_history=5),
                        KerasPolicy(featurizer)])

I forgot to make this change inside the train_init.py file and this is why it was failing. I have made a commit with an updated code so it should be fixed by now. Give it a go let me know if the problem persists :)

dilankadias commented 6 years ago

@JustinaPetr : Thank you so much, I solved the issue. But I encountered another problem and I have sent you an email to your email address mentioned in your github account (juste@rasa.com). Can you please check your your email inbox? Thanks,

ranjan-sumit commented 6 years ago

(base) C:\Users\sumit\Desktop\Xtra1\chatbot\Python Bot\WeatherBot\Mybot>python dialogue_management_model.py C:\Users\sumit\Anaconda3\lib\site-packages\h5py__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Using TensorFlow backend. Traceback (most recent call last): File "dialogue_management_model.py", line 54, in train_dialogue() File "dialogue_management_model.py", line 30, in train_dialogue interpreter=interpreter) NameError: name 'interpreter' is not defined

(base) C:\Users\sumit\Desktop\Xtra1\chatbot\Python Bot\WeatherBot\Mybot>python dialogue_management_model.py Traceback (most recent call last): File "dialogue_management_model.py", line 17, in from rasa_core.utils import EndpointConfig ImportError: cannot import name 'EndpointConfig'

Please help with this issue

monosijbagchi commented 5 years ago

after passing the following parameter . agent = Agent('weather_domain.yml', policies=[MemoizationPolicy(max_history=5), KerasPolicy(featurizer)]) I am getting this error KerasPolicy(featurizer)]) NameError: name 'featurizer' is not defined

serdarbozoglan commented 5 years ago

I am having the same problem.

serdarbozoglan commented 5 years ago

@dilankadias I just checked my code and found that I actually left one parameter as per old version of Rasa Core, so thanks a lot for reporting this! :) . Since the release of Rasa Core v0.9.0 the parameter max_history has to be priovided directly to the policy, for example:

agent = Agent(domain_file,
              policies=[MemoizationPolicy(max_history=5),
                        KerasPolicy(featurizer)])

I forgot to make this change inside the train_init.py file and this is why it was failing. I have made a commit with an updated code so it should be fixed by now. Give it a go let me know if the problem persists :)

The code is not working I got an errof "Featurizer is not defined" Please help with the issue. Thanks

i-am-dejan commented 5 years ago

I ran into the same problem. Since I couldn’t find anything on the internet, I took a closer look at @JustinaPetr ’s GitHub repo and tried it out for myself with the help of her files. For me this example works perfect:

from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals

import logging

from rasa_core.agent import Agent
from rasa_core.policies.keras_policy import KerasPolicy
from rasa_core.policies.memoization import MemoizationPolicy

if __name__ == '__main__':
        logging.basicConfig(level='INFO')

        training_data_file = './data/stories.md'
        model_path = './models/dialogue'

        agent = Agent('my_domain.yml', policies = [MemoizationPolicy(max_history=2), KerasPolicy(max_history=3)])

        data = agent.load_data(training_data_file)
        agent.train(data)
        agent.persist(model_path)

If you have problems with _trainonline.py, check out Justina's GitHub repo. She recently updated this Python script.

lingineni555 commented 5 years ago

from future import absolute_import from future import division from future import unicode_literals

import logging

from rasa_core.agent import Agent from rasa_core.policies.keras_policy import KerasPolicy from rasa_core.policies.memoization import MemoizationPolicy from rasa_core.featurizers import (MaxHistoryTrackerFeaturizer, BinarySingleStateFeaturizer)

if name == 'main': logging.basicConfig(level='INFO')

training_data_file = './data/stories.md'# provided the file with sample stories
model_path = './models/dialogue' # Path where i store my model

featurizer = MaxHistoryTrackerFeaturizer(BinarySingleStateFeaturizer(), max_history=5)
agent = Agent('restaurant_domain.yml', policies = [MemoizationPolicy(max_history = 4), KerasPolicy(featurizer)]) # provided the domain file

agent.train(
        training_data_file,
        augmentation_factor = 50,
        #max_history = 4,    # comment this to solve the issue
        epochs = 500,
        batch_size = 30,
        validation_split = 0.2)

agent.persist(model_path)

For me commenting the max_history in agent.train method solved the issue

Rabinpal1 commented 5 years ago

if this change done then new error is appearing Traceback (most recent call last): File ".\train_init.py", line 1, in from future import absolute_import ImportError: cannot import name 'absolute_import'

Rabinpal1 commented 5 years ago

@dilankadias I just checked my code and found that I actually left one parameter as per old version of Rasa Core, so thanks a lot for reporting this! :) . Since the release of Rasa Core v0.9.0 the parameter max_history has to be priovided directly to the policy, for example:

agent = Agent(domain_file,
              policies=[MemoizationPolicy(max_history=5),
                        KerasPolicy(featurizer)])

I forgot to make this change inside the train_init.py file and this is why it was failing. I have made a commit with an updated code so it should be fixed by now. Give it a go let me know if the problem persists :)

please share the latest code link where its fixed