示例#1
0
def createModel(dense1, dropout1, dense2, dropout2):
    model = Sequential()
    model.add(Dense(dense1, input_shape=(dims,), init='he_uniform', W_regularizer=regularizers.l1(0.0005)))
    model.add(Activation('relu'))
    model.add(Dropout(dropout1))# input dropout
    model.add(Dense(dense2, init='he_uniform'))
    model.add(Activation('relu'))
    model.add(Dropout(dropout2))
    model.add(Dense(2, init='he_uniform'))
    model.add(Activation('sigmoid'))
    model.compile(loss='binary_crossentropy', optimizer="adagrad")
    return model
示例#2
0
def createModel(x):
    model = Sequential()
    model.add(Dense(x[0], input_shape=(dims,), init='he_uniform', W_regularizer=regularizers.l1(0.0005)))
    model.add(Activation('relu'))
    model.add(Dropout(x[1]))# input dropout
    model.add(Dense(x[2], init='he_uniform'))
    model.add(Activation('relu'))
    model.add(Dropout(x[3]))
    model.add(Dense(nb_classes, init='he_uniform'))
    model.add(Activation('sigmoid'))
    model.compile(loss='binary_crossentropy', optimizer="adagrad")
    return model
def createModel():
    model = Sequential()
    model.add(Dense(int(85), input_shape=(dims,), init='he_uniform', W_regularizer=regularizers.l1(0.0005)))
    model.add(Dropout(0.05))  # input dropout
    model.add(PReLU())
    model.add(BatchNormalization())
    model.add(Dropout(0.1))
    model.add(Dense(int(83)))
    model.add(PReLU())
    model.add(BatchNormalization())
    model.add(Dropout(0.15))
    model.add(Dense(nb_classes))
    model.add(Activation('sigmoid'))
    model.compile(loss='binary_crossentropy', optimizer="adam")
    return model
示例#4
0
def createModel(dense1, dropout1, dense2, dropout2):
    model = Sequential()
    model.add(
        Dense(dense1,
              input_shape=(dims, ),
              init='he_uniform',
              W_regularizer=regularizers.l1(0.0005)))
    model.add(Activation('relu'))
    model.add(Dropout(dropout1))  # input dropout
    model.add(Dense(dense2, init='he_uniform'))
    model.add(Activation('relu'))
    model.add(Dropout(dropout2))
    model.add(Dense(2, init='he_uniform'))
    model.add(Activation('sigmoid'))
    model.compile(loss='binary_crossentropy', optimizer="adagrad")
    return model
示例#5
0
def kerascv(dense1, dense2, epochs):
    ival = IntervalEvaluation(validation_data=(x1, y1), interval=1)

    pred_sum = 0
    for k in range(1):
        model = Sequential()
        model.add(
            Dense(int(dense1),
                  input_shape=(dims, ),
                  init='he_uniform',
                  W_regularizer=regularizers.l1(0.0005)))
        model.add(Dropout(0.05))  #    input dropout
        model.add(PReLU())
        model.add(BatchNormalization())
        model.add(Dropout(0.1))
        model.add(Dense(int(dense2)))
        model.add(PReLU())
        model.add(BatchNormalization())
        model.add(Dropout(0.15))
        model.add(Dense(nb_classes))
        model.add(Activation('sigmoid'))
        model.compile(loss='binary_crossentropy', optimizer="adam")
        model.fit(x0,
                  y0,
                  nb_epoch=int(epochs),
                  batch_size=128,
                  verbose=0,
                  callbacks=[ival])

        preds = model.predict_proba(x1, batch_size=64, verbose=0)[:, 1]
        pred_sum += preds
        pred_average = pred_sum / (k + 1)
        del model

    loss = auc(y1[:, 1], pred_average)
    return loss