Keras | TypeError: __init __ () missing 1 required positional argument: 'nb_col'

I'm currently trying to embed this tutorial code in my own convnet.py file, but am getting an error. Textbook

This is a complete error:

Traceback (most recent call last):
    File "convnet.py", line 6, in <module>
        model.add(Conv2D(32, (3, 3), input_shape=(3, 150, 150)))
TypeError: __init__() missing 1 required positional argument: 'nb_col'

Here are the first 10 lines where the program goes wrong:

from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense

model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=(3, 150, 150)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

The code is in the convnet.py file, and I run the file as follows:   python convnet.py

+6
source share
1 answer

You are probably using an old version of Keras that had the following signature:

Conv2D(self, nb_filter, nb_row, nb_col, ...)

In this old version, you define the level of conv as:

model.add(Conv2D(32, 3, 3, input_shape=(3, 150, 150)))

You can check the version you are working with:

import keras
print(keras.__version__)

I suggest you update Keras.

+18
source

Source: https://habr.com/ru/post/1015929/


All Articles