Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dilankadias opened this issue Jun 16, 2018 · 10 comments

Comments

@dilankadias
Copy link

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
Copy link
Owner

@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
Copy link
Author

@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
Copy link

(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
Copy link

monosijbagchi commented Nov 27, 2018

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
Copy link

I am having the same problem.

@serdarbozoglan
Copy link

@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
Copy link

i-am-dejan commented Feb 8, 2019

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 train_online.py, check out Justina's GitHub repo. She recently updated this Python script.

@lingineni555
Copy link

lingineni555 commented Mar 23, 2019

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
Copy link

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
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants