md abdul karim
md abdul karim

Reputation: 73

TypeError: init() missing 1 required positional argument: 'kernel_size'

This is the error I get on my program. anyone can say what is the problem of my code.

32 filters
input shape 100 rows 100 cols 15 patchsize
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-42-4fac16b2e337> in <module>
      3 print('input shape', img_rows, 'rows', img_cols, 'cols', patch_size, 'patchsize')
      4 
----> 5 model.add(Convolution3D(
      6     nb_filters[0],
      7     kernel_dim1=1, # depth

TypeError: __init__() missing 1 required positional argument: 'kernel_size'

This is my code what is the problem I don't understand if you know the solution please suggest me thank you. i am using tf-2.3 python 3.7

model = Sequential()
print(nb_filters[0], 'filters')
print('input shape', img_rows, 'rows', img_cols, 'cols', patch_size, 'patchsize')

model.add(Convolution3D(
    nb_filters[0],
    kernel_dim1=1, # depth
    kernel_dim2=nb_conv[0], # rows
    kernel_dim3=nb_conv[1], # cols
    input_shape=(1, img_rows, img_cols, patch_size),
    activation='relu'
))

model.add(MaxPooling3D(pool_size=(1, nb_pool[0], nb_pool[0])))

model.add(Dropout(0.2))

model.add(Flatten())

model.add(Dense(128, init='normal', activation='relu'))

model.add(Dropout(0.2))

model.add(Dense(nb_classes,init='normal'))

model.add(Activation('softmax'))
#optimizer adam,sgd,RMSprop,Adagrad,Adadelta,Nadam,
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

Upvotes: 1

Views: 1799

Answers (0)

Related Questions