conv2d() got an unexpected keyword argument 'border_mode'
Solution 1
Well, there isn't a border_mode
in keras.
There is padding='valid'
or padding='same'
.
Always check the documentation to use the layers and functions properly.
Solution 2
Just as a side note in case anyone still has this issue, this is an issue of backward compatibility with Keras1.x. "border_mode" used to exist as an argument to the Convolution2D class in (at least) Keras1.1.0 and as such is still hanging around in a lot of older code.
In Keras2 series (I referenced 2.3.1) you will see that almost the entire API to Convolution2D has changed, so if you are porting a repository using an older version of Keras I doubt border_mode would be the biggest of your concerns.
Related videos on Youtube
mageshwaran
Updated on June 04, 2022Comments
-
mageshwaran almost 2 years
when i try to run this code with keras-2.1.3 and theano-1.0.1 https://github.com/marcellacornia/sam/blob/master/attentive_convlstm.py
def get_initial_states(self, x): initial_state = K.sum(x, axis=1) initial_state = K.conv2d(initial_state, K.zeros((self.nb_filters_out, self.nb_filters_in, 1, 1)), border_mode='same') initial_states = [initial_state for _ in range(len(self.states))] return initial_states Traceback (most recent call last): File "main.py", line 63, in <module> m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps])) File "E:\sam-master\models.py", line 136, in sam_resnet nb_cols=3, nb_rows=3)(att_convlstm) File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 617, in __call__ output = self.call(inputs, **kwargs) File "E:\sam-master\attentive_convlstm.py", line 143, in call initial_states = self.get_initial_states(x) File "E:\sam-master\attentive_convlstm.py", line 42, in get_initial_states initial_state = K.conv2d(initial_state, K.zeros((self.nb_filters_out, self.nb_filters_in, 1, 1)), border_mode='same') TypeError: conv2d() got an unexpected keyword argument 'border_mode'
-
Matt Messersmith about 6 yearsI upvoted, because answers like these are somehow still needed. 2018 and we still aren't reading the docs, tsk tsk
-
mageshwaran about 6 yearsthanks for the help, after I change this I get this error ValueError: It seems that you are using the Keras 2 and you are passing both
kernel_size
andstrides
as integer positional arguments. For safety reasons, this is disallowed. Passstrides
as a keyword argument instead. i'm try to run this code with keras 2.1.3 -
Daniel Möller about 6 yearsAre you sure the error is in the same line as before? --- You should probably post another question for that error, showing in detail where the error appears. (If you consider that my answer solved your initial problem, please mark it as answered).
-
Daniel Möller about 6 yearsIf the problem is indeed in the same line, try:
K.conv2d(x=initial_state,kernel= np.zeros((self.nb_filters_out, self.nb_filters_in, 1, 1)), padding='same')
-
Daniel Möller about 6 yearsNotice that the expected shape for the filter is actually (sizeX, sizeY, inputChannels, outputChannels).