Ejemplo n.º 1
0
def stem(x):
    """
    Stem fo the pure InceptionV4 and Inception-ResNet-V2
    """
    out = conv3x3(x, 32, stride=2, padding="VALID", batch_norm=use_batch_norm)
    out = conv3x3(out, 32, stride=1, padding="VALID", batch_norm=use_batch_norm)
    out = conv3x3(out, 64, stride=1, padding="SAME", batch_norm=use_batch_norm)

    out1 = max_pool_3x3(out, stride=2, padding="VALID")
    out2 = conv3x3(out, 96, stride=2, padding="VALID", batch_norm=use_batch_norm)

    out = concat(3, [out1, out2])

    out1 = conv1x1(out, 64, batch_norm=use_batch_norm)
    out1 = conv3x3(out1, 96, padding="VALID", batch_norm=use_batch_norm)

    out2 = conv1x1(out, 64, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, 64, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, 64, batch_norm=use_batch_norm)
    out2 = conv3x3(out2, 96, padding="VALID", batch_norm=use_batch_norm)

    out = concat(3, [out1, out2])

    out1 = conv3x3(out, 192, stride=2, padding="VALID", batch_norm=use_batch_norm)
    out2 = max_pool_3x3(out, stride=2, padding="VALID")

    out = concat(3, [out1, out2])

    return out
Ejemplo n.º 2
0
def inceptionB(out):
    out1 = conv1x1(out, 384, batch_norm=use_batch_norm)

    out2 = conv1x1(out, 192, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, 224, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, 256, batch_norm=use_batch_norm)

    out3 = conv1x1(out, 192, batch_norm=use_batch_norm)
    out3 = conv7x1(out3, 192, batch_norm=use_batch_norm)
    out3 = conv1x7(out3, 224, batch_norm=use_batch_norm)
    out3 = conv7x1(out3, 224, batch_norm=use_batch_norm)
    out3 = conv1x7(out3, 256, batch_norm=use_batch_norm)

    out4 = avg_pool_3x3(out)
    out4 = conv1x1(out4, 128, batch_norm=use_batch_norm)

    return concat(3, [out1, out2, out3, out4])
Ejemplo n.º 3
0
def inception7C(out, num_1x1, num_d7_red, num_d7_1, num_d7_2, num_q7_red, num_q7_1, num_q7_2, num_q7_3, num_q7_4, proj):
    out1 = conv1x1(out, num_1x1, batch_norm=use_batch_norm)

    out2 = conv1x1(out, num_d7_red, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, num_d7_1, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, num_d7_2, batch_norm=use_batch_norm)

    out3 = conv1x1(out, num_q7_red, batch_norm=use_batch_norm)
    out3 = conv7x1(out3, num_q7_1, batch_norm=use_batch_norm)
    out3 = conv1x7(out3, num_q7_2, batch_norm=use_batch_norm)
    out3 = conv7x1(out3, num_q7_3, batch_norm=use_batch_norm)
    out3 = conv1x7(out3, num_q7_4, batch_norm=use_batch_norm)

    out4 = avg_pool_3x3(out)
    out4 = conv1x1(out4, proj, batch_norm=use_batch_norm)

    return concat(3, [out1, out2, out3, out4])
Ejemplo n.º 4
0
def inceptionB(out):
    out1 = conv1x1(out, 384, batch_norm=use_batch_norm)

    out2 = conv1x1(out, 192, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, 224, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, 256, batch_norm=use_batch_norm)

    out3 = conv1x1(out, 192, batch_norm=use_batch_norm)
    out3 = conv7x1(out3, 192, batch_norm=use_batch_norm)
    out3 = conv1x7(out3, 224, batch_norm=use_batch_norm)
    out3 = conv7x1(out3, 224, batch_norm=use_batch_norm)
    out3 = conv1x7(out3, 256, batch_norm=use_batch_norm)

    out4 = avg_pool_3x3(out)
    out4 = conv1x1(out4, 128, batch_norm=use_batch_norm)

    return concat(3, [out1, out2, out3, out4])
Ejemplo n.º 5
0
def inception7C(out, num_1x1, num_d7_red, num_d7_1, num_d7_2, num_q7_red,
                num_q7_1, num_q7_2, num_q7_3, num_q7_4, proj):
    out1 = conv1x1(out, num_1x1, batch_norm=use_batch_norm)

    out2 = conv1x1(out, num_d7_red, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, num_d7_1, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, num_d7_2, batch_norm=use_batch_norm)

    out3 = conv1x1(out, num_q7_red, batch_norm=use_batch_norm)
    out3 = conv7x1(out3, num_q7_1, batch_norm=use_batch_norm)
    out3 = conv1x7(out3, num_q7_2, batch_norm=use_batch_norm)
    out3 = conv7x1(out3, num_q7_3, batch_norm=use_batch_norm)
    out3 = conv1x7(out3, num_q7_4, batch_norm=use_batch_norm)

    out4 = avg_pool_3x3(out)
    out4 = conv1x1(out4, proj, batch_norm=use_batch_norm)

    return concat(3, [out1, out2, out3, out4])
Ejemplo n.º 6
0
def inception7D(out, num_3x3_red, num_3x3, num_d7_3x3_red, num_d7_1, num_d7_2, num_d7_3x3):
    out1 = conv1x1(out, num_3x3_red, batch_norm=use_batch_norm)
    out1 = conv3x3(out1, num_3x3, stride=2, batch_norm=use_batch_norm)

    out2 = conv1x1(out, num_d7_3x3_red, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, num_d7_1, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, num_d7_2, batch_norm=use_batch_norm)
    out2 = conv3x3(out2, num_d7_3x3, stride=2, batch_norm=use_batch_norm)

    out3 = max_pool_3x3(out, stride=2)

    return concat(3, [out1, out2, out3])
Ejemplo n.º 7
0
def reductionB(out):
    out1 = conv1x1(out, 192, batch_norm=use_batch_norm)
    out1 = conv3x3(out1, 192, stride=2, padding="VALID", batch_norm=use_batch_norm)

    out2 = conv1x1(out, 256, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, 256, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, 320, batch_norm=use_batch_norm)
    out2 = conv3x3(out2, 320, stride=2, padding="VALID", batch_norm=use_batch_norm)

    out3 = max_pool_3x3(out, stride=2, padding="VALID")

    return concat(3, [out1, out2, out3])
Ejemplo n.º 8
0
def inception7D(out, num_3x3_red, num_3x3, num_d7_3x3_red, num_d7_1, num_d7_2,
                num_d7_3x3):
    out1 = conv1x1(out, num_3x3_red, batch_norm=use_batch_norm)
    out1 = conv3x3(out1, num_3x3, stride=2, batch_norm=use_batch_norm)

    out2 = conv1x1(out, num_d7_3x3_red, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, num_d7_1, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, num_d7_2, batch_norm=use_batch_norm)
    out2 = conv3x3(out2, num_d7_3x3, stride=2, batch_norm=use_batch_norm)

    out3 = max_pool_3x3(out, stride=2)

    return concat(3, [out1, out2, out3])
Ejemplo n.º 9
0
def reductionB(out):
    out1 = conv1x1(out, 192, batch_norm=use_batch_norm)
    out1 = conv3x3(out1,
                   192,
                   stride=2,
                   padding="VALID",
                   batch_norm=use_batch_norm)

    out2 = conv1x1(out, 256, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, 256, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, 320, batch_norm=use_batch_norm)
    out2 = conv3x3(out2,
                   320,
                   stride=2,
                   padding="VALID",
                   batch_norm=use_batch_norm)

    out3 = max_pool_3x3(out, stride=2, padding="VALID")

    return concat(3, [out1, out2, out3])
Ejemplo n.º 10
0
def stem(x):
    """
    Stem fo the pure InceptionV4 and Inception-ResNet-V2
    """
    out = conv3x3(x, 32, stride=2, padding="VALID", batch_norm=use_batch_norm)
    out = conv3x3(out,
                  32,
                  stride=1,
                  padding="VALID",
                  batch_norm=use_batch_norm)
    out = conv3x3(out, 64, stride=1, padding="SAME", batch_norm=use_batch_norm)

    out1 = max_pool_3x3(out, stride=2, padding="VALID")
    out2 = conv3x3(out,
                   96,
                   stride=2,
                   padding="VALID",
                   batch_norm=use_batch_norm)

    out = concat(3, [out1, out2])

    out1 = conv1x1(out, 64, batch_norm=use_batch_norm)
    out1 = conv3x3(out1, 96, padding="VALID", batch_norm=use_batch_norm)

    out2 = conv1x1(out, 64, batch_norm=use_batch_norm)
    out2 = conv1x7(out2, 64, batch_norm=use_batch_norm)
    out2 = conv7x1(out2, 64, batch_norm=use_batch_norm)
    out2 = conv3x3(out2, 96, padding="VALID", batch_norm=use_batch_norm)

    out = concat(3, [out1, out2])

    out1 = conv3x3(out,
                   192,
                   stride=2,
                   padding="VALID",
                   batch_norm=use_batch_norm)
    out2 = max_pool_3x3(out, stride=2, padding="VALID")

    out = concat(3, [out1, out2])

    return out