def _get_adjacency_lists(network):
 ins = defaultdict(list)
 outs = defaultdict(list)
 lookup = {repr(layer): index for (index, layer) in enumerate(network)}
 for current_layer in network:
  if hasattr(current_layer, 'input_layers'):
   layer_ins = current_layer.input_layers
  elif hasattr(current_layer, 'input_layer'):
   layer_ins = [current_layer.input_layer]
  else:
   layer_ins = []
  ins[lookup[repr(current_layer)]].extend([lookup[repr(l)] for l in layer_ins])
  for l in layer_ins:
   outs[lookup[repr(l)]].append(lookup[repr(current_layer)])
 return (ins, outs)

def _get_adjacency_lists ( network ) : ins = defaultdict ( list ) outs = defaultdict ( list ) lookup = { repr ( layer ) : index for ( index , layer ) in enumerate ( network ) } for current_layer in network : if hasattr ( current_layer , 'input_layers' ) : layer_ins = current_layer . input_layers elif hasattr ( current_layer , 'input_layer' ) : layer_ins = [ current_layer . input_layer ] else : layer_ins = [ ] ins [ lookup [ repr ( current_layer ) ] ] . extend ( [ lookup [ repr ( l ) ] for l in layer_ins ] ) for l in layer_ins : outs [ lookup [ repr ( l ) ] ] . append ( lookup [ repr ( current_layer ) ] ) return ( ins , outs )
returns adjacency lists for each layer in network .