def merge_indep_net_spec(net_specs, suffix_fmt='_nidx_%02d'):
    
    data_tops = [l.top for n in net_specs for l in n.layer if l.type.lower() == 'data']
    data_tops = Set([item for sublist in data_tops for item in sublist])
    
    for idx, n in enumerate(net_specs):
    
        suffix = suffix_fmt % idx
        throw_away = []
        for l in n.layer:
            if l.type.lower() != 'data':
                
                l.name += suffix
                
                if np.prod([p.lr_mult for p in l.param]) == 0:
                    print "LAYER WITH FIXED WEIGHTS. MAKE SHARED?"
                    
                for b in list(l.bottom):
                    l.bottom.remove(b)
                    if b not in data_tops:
                        l.bottom.append(unicode(b+suffix))
                    else:
                        l.bottom.append(unicode(b)) # preserve order of layer bottoms, label as bottom has to come last
                    
                for b in list(l.top):
                    l.top.remove(b)
                    if data_tops not in b:
                        l.top.append(unicode(b+suffix))
                    else:
                        l.top.append(unicode(b)) # preserve order of layer tops
                        
            elif idx > 0:
                throw_away.append(l)
                
        for l in throw_away:
            n.layer.remove(l) # Data layers of first net only
                
    proto_str = ''    
    for idx, n in enumerate(net_specs):
        
        s = text_format.MessageToString(n)
        if idx > 0 and s.startswith("name:"):
            _, s = s.split('\n', 1)
        proto_str += s
        
    return proto_str
dataset/ETHPy150Open kashefy/nideep/nideep/nets/net_merge.py/merge_indep_net_spec/swapped operands of `not in`