0

i'm trying to make a simple classification model for the cifar-10 dataset. The model fails when it gets to Maxpooling fuction. It says that it has the incorrect Syntax but for the life of me i cannot figure out whats wrong.

Is it the version of keras i'm using? when i add maxpooling to the model with a size of 2, 2 it don't work and in the documentation, i am doing the exact same thing which makes me think its a version problem.

Sorry if the problem is obvious

 model = Sequential()
 model.add(Conv2D(32, (3,3), padding = 'same', input_shape=(32,32,3)))

 model.add(Activation('relu')

 model.add(MaxPooling2D(pool_size=(2, 2)))

 model.add(Dropout(0.25))

model.add(Flatten())

model.add(Dense(512))

model.add(Activation('relu')

model.add(Dropout(0.5))

model.add(Dense(10))

model.add(Activation('softmax'))

model.summary()
Darman
  • 175
  • 10
  • Each time you add a `relu Activation` layer you forgot an end `)`. – Chrispresso Oct 24 '19 at 17:38
  • @Chrispresso I know i'm such a idiot, god knows how long i was reading the documentation for but thank you so much. If i might ask you, for a data scientist to get hired is it a good route to do kaggle datasets – Darman Oct 24 '19 at 17:39
  • I would say it depends. But honestly it doesn't hurt. I really enjoy doing Kaggle problems because I get to try ideas on datasets and then compare how other people went about the problem. This has helped me a lot in learning more efficient ways of cleaning data, using t-sne for visualization, auto-encoders, etc. In school you do problem sets in math, chemistry, writing, etc. to get better at those topics. I think Kaggle is a great way to improve your skills as a data scientist. – Chrispresso Oct 24 '19 at 17:43

1 Answers1

3

Max pooling does not have any issue.your issue is you are missing some brackets in the previous line. find below the corrected code

model = Sequential()
model.add(Conv2D(32, (3,3), padding = 'same', input_shape=(32,32,3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())

model.add(Dense(512))

model.add(Activation('relu'))

model.add(Dropout(0.5))

model.add(Dense(10))

model.add(Activation('softmax'))

model.summary()

Hope this helps.

ArunJose
  • 1,999
  • 1
  • 10
  • 33
  • It doesn't show the option just yet, think i have to wait a little – Darman Oct 24 '19 at 17:40
  • Could i ask you a question? is it a good idea to do kaggle datasets if you want to be a data scientist. I'm in my last year and i don't know what to showcase outside uni – Darman Oct 24 '19 at 17:42
  • kaggle has been and is always the best for you to start with, as you will start to work with something similar to real. Also good to follow along with some MOOCS to have your concepts and base strong. – ArunJose Oct 24 '19 at 17:44