コード例 #1
0
def build_model():
    utils.set_nn_config()
    inp = Input(config.MODULE_INPUT_DIM)

    layer = inp

    layer = utils.conv_layer(layer, CONV_FILTERS, KERNEL_SIZE,
                             REGULARIZER_CONST)

    for _ in range(CONV_LAYERS):
        layer = utils.conv_layer(layer, CONV_FILTERS, KERNEL_SIZE,
                                 REGULARIZER_CONST)

    out = output_layer(layer)
    model = Model(inputs=inp, outputs=out)
    compile_model(model)

    return model
コード例 #2
0
def build_model():
    utils.set_nn_config()
    inp = Input(config.SYMBOLS_INPUT_DIM)

    layer = utils.conv_layer(inp, CONV_FILTERS, KERNEL_SIZE, REGULARIZER_CONST)
    layer = utils.conv_layer(layer, CONV_FILTERS*2, KERNEL_SIZE, REGULARIZER_CONST)
    layer = Dropout(0.25)(layer)
    layer = MaxPooling2D(pool_size=(2, 2), padding="same")(layer)
    layer = Dense(DENSE_UNITS, activation='relu')(layer)
    layer = MaxPooling2D(pool_size=(2, 2), padding="same")(layer)
    layer = Flatten()(layer)
    layer = Dense(DENSE_UNITS // 2, activation='relu')(layer)
    layer = Dropout(0.5)(layer)
    out = Dense(config.SYMBOLS_OUTPUT_DIM, activation='softmax')(layer)

    model = Model(inputs=inp, outputs=out)

    compile_model(model)

    return model
コード例 #3
0
def build_model():
    sess = utils.get_nn_config()
    graph = tf.Graph()
    inp = Input(config.MODULE_INPUT_DIM)

    layer = inp

    layer = utils.conv_layer(layer, CONV_FILTERS, KERNEL_SIZE,
                             REGULARIZER_CONST)

    for i in range(CONV_LAYERS):
        layer = utils.conv_layer(layer, CONV_FILTERS, KERNEL_SIZE,
                                 REGULARIZER_CONST)
        #if i % 3 == 0:
        #    layer = Dropout(0.3)(layer)

    out = output_layer(layer)
    model = Model(inputs=inp, outputs=out)
    compile_model(model)
    model._make_predict_function()

    return model, graph, sess
コード例 #4
0
def build_model():
    sess = utils.get_nn_config()
    graph = Graph()
    inp = Input(config.SYMBOLS_INPUT_DIM)

    layer = utils.conv_layer(inp, CONV_FILTERS, KERNEL_SIZE, REGULARIZER_CONST)
    layer = utils.conv_layer(layer, CONV_FILTERS * 2, KERNEL_SIZE,
                             REGULARIZER_CONST)
    layer = Dropout(0.25)(layer)
    layer = MaxPooling2D(pool_size=(2, 2), padding="same")(layer)
    layer = Dense(512, activation='relu')(layer)
    layer = MaxPooling2D(pool_size=(2, 2), padding="same")(layer)
    layer = Flatten()(layer)
    layer = Dense(256, activation='relu')(layer)
    layer = Dropout(0.5)(layer)
    out = Dense(config.SYMBOLS_OUTPUT_DIM, activation='softmax')(layer)

    model = Model(inputs=inp, outputs=out)

    compile_model(model)
    model._make_predict_function()

    return model, graph, sess