예제 #1
0
def create_convnet(theta, is_tr=True):
    # input
    a0 = T.matrix("x")
    a00 = a0.reshape((a0.shape[0], 1, 28, 28))

    # I: conv pool
    theta1 = [theta[0], theta[1]]
    sz1_pool = (2, 2)
    a1 = models.create_conv_pool_tanh(a00, theta1, sz1_pool)

    # II: conv pool
    theta2 = [theta[2], theta[3]]
    sz2_pool = (2, 2)
    a2 = models.create_conv_pool_tanh(a1, theta2, sz2_pool)

    # III: fc + dropout
    theta3 = [theta[4], theta[5]]
    if is_tr:
        a3 = models.create_dropout(models.create_linear_sigmoid(a2.flatten(2), theta3), trng=trng)
    else:
        a3 = models.create_dropout(models.create_linear_sigmoid(a2.flatten(2), theta3), trng=None)

    # IV: fc, output
    theta4 = [theta[6], theta[7]]
    a4 = models.create_linear(a3, theta4)

    return a0, a4
예제 #2
0
def create_LR(theta, is_tr=True):
    # Input
    x = T.matrix('x')

    # output layer
    w3, b3 = theta[0], theta[1]
    f = models.create_linear(x, (w3, b3))

    return x, f