TyperError in Keras Policy

While using this snippets i am getting batch_size error


TypeError: fit() got multiple values for keyword argument ‘batch_size’.

I have passed single argument only as you can see in the above snippet. I have read that it is generally caused due to the following reasons mentioned in blogpost ‘Got multiple values for argument’ error with keyword arguments in Python classes « Robin's Blog Does my Dependency creating this issue or Something else. Sorry if the question is very basic, I am not expert at ML and deep learning. Just begin with rasa first time.

1 Like

I got the same error while I wanted to retrain my core (dialogue) model. The error stems for example from this line when you are training a KerasPolicy: rasa_core/keras_policy.py at master · RasaHQ/rasa_core · GitHub

# filter out kwargs that cannot be passed to fit
params = self._get_valid_params(self.model.fit, **kwargs)

whereas the self._get_valid_params( … ) method is implemented for all policies and does not correctly filter out the params (or does it?). Well, at least we end up with the issue/error @this-is-r-gaurav mentioned.

May I suggest to additionally update the kwargs or params (whatever shall take precedence) to fix the issue? For line rasa_core/keras_policy.py at master · RasaHQ/rasa_core · GitHub and following this would change the code piece

self.model.fit(shuffled_X, shuffled_y,


self.model.fit(shuffled_X, shuffled_y,
    **{'epochs': self.epochs, 'batch_size': self.batch_size, **params})  # params take precedence

What do you people think?

This method actually works. But I think in new version 0.12.0 on wards, we have to give keras policy in a configuration yml file. You can try this out.

You can check this out

Thank you for your reply @rohitharitash. Though, for consistency, can you provide a programmatic example? I am not a hundred percent sure how to pass on the configuration file from python.