Hi
when i try to run this code
https://github.com/marcellacornia/sam
FileName : 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
using keras-2.1.3 and theano-1.0.1
i get this error
UserWarning: Update your Conv2D call to the Keras 2 API
TypeError: conv2d() got an unexpected keyword argument 'border_mode'
@Mageshwaran2314
border_mode='same' is a keyword argument in Keras1. You should use padding='same' in Keras2.
Thanks for the answer
after I change this, I got this error
Using Theano backend.
E:sam-master\dcn_resnet.py:137: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(64, (7, 7), name="conv1", strides=(2, 2))
x = Convolution2D(64, 7, 7, subsample=(2, 2), name='conv1')(x)
E:sam-master\dcn_resnet.py:50: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(64, (1, 1), name="res2a_branch2a", strides=(1, 1))
name=conv_name_base + '2a')(input_tensor)
Traceback (most recent call last):
File "main.py", line 63, in
m = Model(input=[x, x_maps], output=sam_resnet([x, x_maps]))
File "E:sam-master\models.py", line 130, in sam_resnet
dcn = dcn_resnet(input_tensor=x[0])
File "E:sam-master\dcn_resnet.py", line 143, in dcn_resnet
x = conv_block(x, 3, [64, 64, 256], stage=2, block='a', strides=(1, 1))
File "E:sam-master\dcn_resnet.py", line 55, in conv_block
name=conv_name_base + '2b')(x)
File "C:\ProgramData\Anaconda3\libsite-packages\keras\legacyinterfaces.py", line 34, in wrapper
args, kwargs, converted = preprocessor(args, kwargs)
File "C:\ProgramData\Anaconda3\libsite-packages\keras\legacyinterfaces.py", line 278, in conv2d_args_preprocessor
'It seems that you are using the Keras 2 '
ValueError: It seems that you are using the Keras 2 and you are passing both kernel_size and strides as integer positional arguments. For safety reasons, this is disallowed. Pass strides as a keyword argument instead.
@Mageshwaran2314
error at dcn_resnet.py line 55
x = Convolution2D(nb_filter2, kernel_size, kernel_size, border_mode='same',
name=conv_name_base + '2b')(x)
The third parameter position is stride, expecting to get a tuple but get a integer. You can replace the second kernel_size with strides
The Conv2D API in Keras 2 is like this:
keras.layers.convolutional.Conv2D(filters, kernel_size, strides=(1, 1), padding='valid', data_format=None, dilation_rate=(1, 1), activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, bias_constraint=None)
It seems that your program is built with Keras 1 and run with Keras 2. I suggest you read the API documentation and make the appropriate changes.
I have the same problem
TypeError Traceback (most recent call last)
32
33 # Test pretrained model
---> 34 model = DenseNet(reduction=0.5, classes=1000, weights_path=weights_path)
35
36 sgd = SGD(lr=1e-2, decay=1e-6, momentum=0.9, nesterov=True)
~\Documents\Francesca\EScd\imagenet_models\densenet121.py in DenseNet(nb_dense_block, growth_rate, nb_filter, reduction, dropout_rate, weight_decay, classes, weights_path)
53 # Add dense blocks
54 for block_idx in range(nb_dense_block - 1):
---> 55 stage = block_idx+2
56 x, nb_filter = dense_block(x, stage, nb_layers[block_idx], nb_filter, growth_rate, dropout_rate=dropout_rate, weight_decay=weight_decay)
57
~\Documents\Francesca\EScd\imagenet_models\densenet121.py in dense_block(x, stage, nb_layers, nb_filter, growth_rate, dropout_rate, weight_decay, grow_nb_filters)
163
164 for i in range(nb_layers):
--> 165 branch = i+1
166 x = conv_block(concat_feat, stage, branch, growth_rate, dropout_rate, weight_decay)
167 #concat_feat = merge([concat_feat, x], mode='concat', concat_axis=concat_axis, name='concat_'+str(stage)+'_'+str(branch))
TypeError: 'module' object is not callable
Most helpful comment
@Mageshwaran2314
border_mode='same'is a keyword argument in Keras1. You should usepadding='same'in Keras2.