New rasa core dialogue training error

Hi

Today I tried latest rasa core to train the model. The code is working fine on 0.11.02 version but i facing some exception with batch_size. Please have a looks.

code - utils.configure_colored_logging(loglevel=“INFO”)

training_data_file = './data/core/new_core_stories.md'
model_path = './models/dialogue'

fallback = FallbackPolicy(fallback_action_name="action_default_fallback", core_threshold=0.25,
                          nlu_threshold=0.3)
featurizer = MaxHistoryTrackerFeaturizer(BinarySingleStateFeaturizer(), max_history=5)

agent = Agent("./new_domain.yml",
              policies=[MemoizationPolicy(max_history=5), KerasPolicy(featurizer), fallback])

training_data = agent.load_data(training_data_file)

agent.train(
    training_data,
    augmentation_factor=50,
    epochs=500,
    batch_size=20,
    validation_split=0.2
)

agent.persist(model_path)

and the logs are -

    018-11-13 13:16:39 INFO     rasa_core.policies.keras_policy  - Fitting model with 264 total samples and a validation split of 0.1
Traceback (most recent call last):
  File "dialogue_management_model.py", line 34, in <module>
    validation_split=0.2
  File "/home/embed/PycharmProjects/FB_grocerBot/venv/lib/python3.5/site-packages/rasa_core/agent.py", line 525, in train
    **kwargs)
  File "/home/embed/PycharmProjects/FB_grocerBot/venv/lib/python3.5/site-packages/rasa_core/policies/ensemble.py", line 67, in train
    policy.train(training_trackers, domain, **kwargs)
  File "/home/embed/PycharmProjects/FB_grocerBot/venv/lib/python3.5/site-packages/rasa_core/policies/keras_policy.py", line 177, in train
    **params)
TypeError: fit() got multiple values for keyword argument 'batch_size'
(venv) embed@embed-Latitude-E7470:~/PycharmProjects/FB_grocerBot$

Thanks

@rohitharitash I had the same problem. My solution is(not reccomended, but it is good if you want something quick)

Go to rasa_core\rasa_core\policies\keras_policy.py in lines 172-177 and delete epochs and batch_size arguemnts from model.fit.

Change :

           params = self._get_valid_params(self.model.fit, **kwargs)

            self.model.fit(shuffled_X, shuffled_y,
                           epochs=self.epochs,
                           batch_size=self.batch_size,
                           **params)

to:

            params = self._get_valid_params(self.model.fit, **kwargs)
            self.model.fit(shuffled_X, shuffled_y,**params)

The problems is inside model.fit where u pass epochs,batch_size and params( epochs and batch_size again) and that’s why u had the error params = self._get_valid_params(self.model.fit, **kwargs)

Then u can pass epochos and batch_size arguments in agent.train()

          agent.train(data, batch_size=50, epochs=1000, validation_split=0.2)

Hello aplamhden,

thank you for pointing out this quick fix. I had the same problem and hope this gets fixed with the new update.