keras激活功能层:model.add激活('relu')提供无效语法

时间:2018-03-05 13:29:47

标签: python deep-learning keras

    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))
请某人应该帮忙。我在python 2.7环境中使用jupyter notebook,上面的代码返回:

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

SyntaxError:语法无效

可能是什么问题?

1 个答案:

答案 0 :(得分:1)

您在此行末尾缺少一个括号:

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