(inputs, output, tokens, adjvec)
return loss, accuracy
create net
create net
create net
def net(inputs, output, tokens, adjvec):
    """
        create net
    """
    num_nodes = len(tokens) // 2

    def slice(vec):
        """
            slice vec
        """
        mat = np.zeros([num_nodes, num_nodes])

        def pos(x):
            """
                pos
            """
            return x * (x - 1) // 2
        for i in range(1, num_nodes):
            mat[0:i, i] = vec[pos(i):pos(i + 1)]
        return mat

    normal_to, reduce_to = np.split(tokens, 2)
    normal_ad, reduce_ad = map(slice, np.split(adjvec, 2))

    x = layers.conv(inputs, FLAGS.width, (3, 3))

    c = 1
    for _ in range(FLAGS.num_cells):
        x = cell(x, normal_to, normal_ad)
        c += 1
    for _ in range(1, FLAGS.num_stages):
        x = cell(x, reduce_to, reduce_ad, downsample=True)
        c += 1
        for _ in range(1, FLAGS.num_cells):
            x = cell(x, normal_to, normal_ad)
            c += 1

    x = layers.bn_relu(x)
    x = layers.global_avgpool(x)
    x = layers.dropout(x)
    logits = layers.fully_connected(x, num_classes)
    x = fluid.layers.softmax_with_cross_entropy(logits, output,
                                                numeric_stable_mode=True)
    loss = fluid.layers.reduce_mean(x)
    accuracy = fluid.layers.accuracy(input=logits, label=output)
    return loss, accuracy
def net ( inputs , output , tokens , adjvec ) : num_nodes = len ( tokens ) // 2 def slice ( vec ) : """
            slice vec
        """ mat = np . zeros ( [ num_nodes , num_nodes ] ) def pos ( x ) : """
                pos
            """ return x * ( x - 1 ) // 2 for i in range ( 1 , num_nodes ) : mat [ 0 : i , i ] = vec [ pos ( i ) : pos ( i + 1 ) ] return mat normal_to , reduce_to = np . split ( tokens , 2 ) normal_ad , reduce_ad = map ( slice , np . split ( adjvec , 2 ) ) x = layers . conv ( inputs , FLAGS . width , ( 3 , 3 ) ) c = 1 for _ in range ( FLAGS . num_cells ) : x = cell ( x , normal_to , normal_ad ) c += 1 for _ in range ( 1 , FLAGS . num_stages ) : x = cell ( x , reduce_to , reduce_ad , downsample = True ) c += 1 for _ in range ( 1 , FLAGS . num_cells ) : x = cell ( x , normal_to , normal_ad ) c += 1 x = layers . bn_relu ( x ) x = layers . global_avgpool ( x ) x = layers . dropout ( x ) logits = layers . fully_connected ( x , num_classes ) x = fluid . layers . softmax_with_cross_entropy ( logits , output , numeric_stable_mode = True ) loss = fluid . layers . reduce_mean ( x ) accuracy = fluid . layers . accuracy ( input = logits , label = output ) return loss , accuracy