def stack(net, level):
    
    n = pu.copy_net_params(net)
    
    enc_prev = None
    dec_prev = None
    enc = None
    dec = None
    for l in n.layer:
        if l.name.lower().endswith('encode%03dneuron' % (level-1)):
            enc = pu.copy_msg(l, LayerParameter)
            
            for b in list(enc.bottom):
                l.bottom.remove(b)
            for t in list(l.top):
                l.bottom.append(unicode(t)) # preserve order of layer bottoms, label as bottom has to come last
            
        elif l.name.lower().endswith('decode%03dneuron' % (level-1)):
            dec_prev = l
            dec = pu.copy_msg(l, LayerParameter)
            
    enc.name = 'encode%03dneuron' % level
    dec.name = level % 'encode%03dneuron'
    
    
    return n
dataset/ETHPy150Open kashefy/nideep/nideep/nets/layerwise.py/stack/swapped operands of `%`