Keras error ‘Keyword argument not understood:’, ‘subsample’


I am currently trying to make a research paper’s source code work. It’s supposed to be able to detect cells on an image using deep learning. The source code is available here :

I’m using Python 3.9.5 and keras 2.5.0.

I’ve been having some issues trying to make this code work properly, I am getting errors that I’m not sure how to resolve. This happens when I compile :

Traceback (most recent call last):

File "D:FacStage", line 126, in <module>

File "D:FacStage", line 87, in train_model = buildModel_U_net(input_dim = (256,256,3))

File "D:FacStage", line 173, in buildModel_U_net
act_ = U_net_base (input_, nb_filter = 64 )

File "D:FacStage", line 123, in U_net_baseblock1 = _conv_bn_relu_x2(nb_filter,3,3)(input)

File "D:FacStage", line 57, in fconv_a = Convolution2D(nb_filter, row, col, subsample = subsample,

File "", line 656, in __init__super(Conv2D, self).__init__(

File "", line 125, in __init__
super(Conv, self).__init__(

File "", line 522, in _method_wrapper
result = method(self, *args, **kwargs)

File "", line 323, in __init__
generic_utils.validate_kwargs(kwargs, allowed_kwargs)

File "", line 1134, in validate_kwargs
raise TypeError(error_message, kwarg)
TypeError: ('Keyword argument not understood:', 'subsample')

From my understanding, there’s an issue with the parameters on line 57 in, they are not recognized ;

conv_a = Convolution2D(nb_filter, row, col, subsample = subsample,
                           init = 'orthogonal', border_mode = 'same',bias = False,
                           W_regularizer = l2(weight_decay),
                           b_regularizer = l2(weight_decay))(input)

I found out if I modified keras configuration’s file and added more "acceptable" parameters in the list on line 312 I wouldn’t get those errors anymore, but it seems weird that this would be the way to go

    allowed_kwargs = {

I’d prefer to only modify the source code on the project and not kera’s, I just don’t understand how. There’s got to be a reason these keywords aren’t in the configuration file, but how am I supposed to make it work then ?



I think the problem is because of version mismatch of Keras. Convolution2D is a deprecated function in Keras 2.5.0 and it has been replaced by Conv2D and the subsample argument has been replaced by stride. You need to either install an older version of Keras like 1.2.2 or modify the code to make it compatible with new Keras.

For more information you may check:

Leave a Reply

Your email address will not be published. Required fields are marked *