简体   繁体   中英

keras activation function layer: model.add Activation('relu') gives invalid syntax

    model = sequential ()
    model.add(convolutional2D(32,3,3 , input_shape = (img_width, 
    img_height,3))
    model.add(Maxpooling2D(pool_size=(2,2)))
    model.add(Activation('relu'))
    model.add(convolutional2D(32,3,3))
    model.add(Activation('relu'))
    model.add(MaxpoolingD2(pooling_size=(2,2)))

    model.add(convolutional2D(32,3,3,))
    model.add(Activation('relu'))
    model.add(Maxpooling2D(pooling_size=(2,2)))

    model.add(Flatten())
    model.add(dense(64))
    model.add(Activation('relu'))
    model.add(dropout(0.5))
    model.add(dense(1))
    model.add(activation(sigmoid))

please someone should help out. I use jupyter notebook in python 2.7 environment and the above code returns:

 File "<ipython-input-11-fab080993955>", line 4
model.add(Activation('relu'))
    ^

SyntaxError: invalid syntax

what could be the problem?

您在此行的末尾缺少括号:

model.add(convolutional2D(32,3,3 , input_shape = (img_width, img_height,3))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM