+1 vote
2 views
in Python by (330 points)

I am working on the following code:

model = Sequential()

 a = keras.layers.advanced_activations.PReLU(init='zero', weights=None) model.add(Dense(64, input_dim=14, init='uniform'))

 model.add(Activation(a))

 model.add(Dropout(0.15)) 

model.add(Dense(64, init='uniform'))

 model.add(Activation('softplus'))

 model.add(Dropout(0.15)) 

model.add(Dense(2, init='uniform'))

 model.add(Activation('softmax'))

 sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True) model.compile(loss='binary_crossentropy', optimizer=sgd)

 model.fit(X_train, y_train, nb_epoch=20, batch_size=16, show_accuracy=True, validation_split=0.2, verbose = 2)

Here the problem is I am getting an error “ TypeError: 'PReLU' object is not callable” at the model.compile line. I have checked all the non-advanced activation function is working , only the advanced activation function is not working. Can anyone explain the solution to this?

1 Answer

+2 votes
by (10.9k points)
edited by

@kavita ,The best way to use PReLU is with the add() method and not wrapping it using Activation class.

Ex:

model = Sequential()

        a = keras.layers.advanced_activations.PReLU(init='zero', weights=None)  

        model.add(Dense(64, input_dim=14, init='uniform'))

        model.add(a)

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...