def stack2params(stack):
 params = []
 for s in stack:
  params.append(s['w'].flatten())
  params.append(s['b'].flatten())
 params = np.concatenate(params)
 net_config = {}
 if (len(stack) == 0):
  net_config['input_size'] = 0
  net_config['layer_sizes'] = []
 else:
  net_config['input_size'] = stack[0]['w'].shape[1]
  net_config['layer_sizes'] = []
  for s in stack:
   net_config['layer_sizes'].append(s['w'].shape[0])
 return (params, net_config)

def stack2params ( stack ) : params = [ ] for s in stack : params . append ( s [ 'w' ] . flatten ( ) ) params . append ( s [ 'b' ] . flatten ( ) ) params = np . concatenate ( params ) net_config = { } if ( len ( stack ) == 0 ) : net_config [ 'input_size' ] = 0 net_config [ 'layer_sizes' ] = [ ] else : net_config [ 'input_size' ] = stack [ 0 ] [ 'w' ] . shape [ 1 ] net_config [ 'layer_sizes' ] = [ ] for s in stack : net_config [ 'layer_sizes' ] . append ( s [ 'w' ] . shape [ 0 ] ) return ( params , net_config )
converts a "stack" structure into a flattened parameter vector and also stores the network configuration .