Пример #1
0
def build_network(deepest=False):
    dropout = [0., 0.1, 0.2, 0.3, 0.4]
    conv = [(64, 3, 3), (128, 3, 3), (256, 3, 3), (512, 3, 3), (512, 2, 2)]
    input = Input(shape=(32, 32, 3))
    output = fractal_net(
        c=3,
        b=5,
        conv=conv,
        drop_path=0.15,
        dropout=dropout,
        #drop_path=0.15, dropout=None,
        deepest=deepest)(input)
    output = Flatten()(output)
    #output = Dense(NB_CLASSES, init='he_normal')(output)
    output = Dense(NB_CLASSES, kernel_initializer='he_normal')(output)
    output = Activation('softmax')(output)
    #model = Model(input=input, output=output)
    model = Model(inputs=input, outputs=output)
    optimizer = SGD(lr=LEARN_START, momentum=MOMENTUM)
    #optimizer = RMSprop(lr=LEARN_START)
    #optimizer = Adam()
    #optimizer = Nadam()
    model.compile(optimizer=optimizer,
                  loss='categorical_crossentropy',
                  metrics=['accuracy'])
    #model.compile(optimizer=optimizer, loss='mean_squared_error', metrics=['accuracy'])
    #plot(model, to_file='model.png')
    return model
Пример #2
0
def build_network(deepest=False):
    dropout = [0., 0.1, 0.2, 0.3, 0.4]
    conv = [(64, 3, 3), (128, 3, 3), (256, 3, 3), (512, 3, 3), (512, 2, 2)]
    input= Input(shape=(3, 32, 32) if K._BACKEND == 'theano' else (32, 32,3))
    output = fractal_net(
        c=3, b=5, conv=conv,
        drop_path=0.15, dropout=dropout,
        deepest=deepest)(input)
    output = Flatten()(output)
    output = Dense(NB_CLASSES, init='he_normal')(output)
    output = Activation('softmax')(output)
    model = Model(input=input, output=output)
    #optimizer = SGD(lr=LEARN_START, momentum=MOMENTUM)
    #optimizer = SGD(lr=LEARN_START, momentum=MOMENTUM, nesterov=True)
    optimizer = Adam()
    #optimizer = Nadam()
    model.compile(optimizer=optimizer, loss='categorical_crossentropy', metrics=['accuracy'])
    plot(model, to_file='model.png', show_shapes=True)
    return model
def build_network(deepest = False):
    dropout = [0., 0., 0., 0., 0.]
    conv = [(64, 3, 3), (128, 3, 3), (256, 3, 3), (512, 3, 3), (512, 2, 2)]
    input = Input(shape = (32, 32, 3))
    output = fractal_net(c = 3, b = 5, conv = conv, drop_path = 0.15, 
                         dropout = dropout, deepest = deepest)(input)
    
    output = Flatten()(output)
    output = Dense(512, kernel_initializer = 'he_normal')(output)
    output = Activation('relu')(output)
    output = Dropout(0.25)(output)
    output = Dense(nb_classes, kernel_initializer = 'he_normal')(output)
    output = Activation('softmax')(output)
    
    model = Model(inputs = input, outputs = output)
    optimizer = SGD(lr = lr, momentum = 0.9, nesterov = True)
#    optimizer = Adam()
    model.compile(optimizer = optimizer, loss = 'categorical_crossentropy', metrics= ['accuracy'])
#    model.summary()    
    
    return model
Пример #4
0
def build_network(deepest=False):
    dropout = [0., 0.1, 0.2, 0.3, 0.4]
    conv = [(64, 3, 3), (128, 3, 3), (256, 3, 3), (512, 3, 3), (512, 2, 2)]
    input = Input(shape=(3, 32, 32))
    output = fractal_net(c=3,
                         b=5,
                         conv=conv,
                         drop_path=0.15,
                         dropout=dropout,
                         deepest=deepest)(input)
    output = Flatten()(output)
    output = Dense(NB_CLASSES, init='he_normal')(output)
    output = Activation('softmax')(output)
    model = Model(input=input, output=output)
    #optimizer = SGD(lr=LEARN_START, momentum=MOMENTUM)
    #optimizer = SGD(lr=LEARN_START, momentum=MOMENTUM, nesterov=True)
    optimizer = Adam()
    #optimizer = Nadam()
    model.compile(optimizer=optimizer,
                  loss='categorical_crossentropy',
                  metrics=['accuracy'])
    plot(model, to_file='model.png', show_shapes=True)
    return model
Пример #5
0
 def f(input):
     return fractal_net(b=b,
                        c=c,
                        conv=b * [(nb_filter, conv_size)],
                        drop_path=drop_path,
                        dropout=b * [dropout])(input)