def cleanedUpGenericNetwork(original_network):
 network = caffe_pb2.NetParameter()
 network.CopyFrom(original_network)
 for (i, layer) in enumerate(network.layer):
  if ('Data' in layer.type):
   assert (layer.type in ['Data']), ('Unsupported data layer type %s' % layer.type)
  elif (layer.type == 'Input'):
   del network.layer[i]
  elif (layer.type == 'InnerProduct'):
   assert layer.inner_product_param.HasField('num_output'), ("Don't leave inner_product_param.num_output unset for generic networks (layer %s)" % layer.name)
 return network

def cleanedUpGenericNetwork ( original_network ) : network = caffe_pb2 . NetParameter ( ) network . CopyFrom ( original_network ) for ( i , layer ) in enumerate ( network . layer ) : if ( 'Data' in layer . type ) : assert ( layer . type in [ 'Data' ] ) , ( 'Unsupported data layer type %s' % layer . type ) elif ( layer . type == 'Input' ) : del network . layer [ i ] elif ( layer . type == 'InnerProduct' ) : assert layer . inner_product_param . HasField ( 'num_output' ) , ( "Don't leave inner_product_param.num_output unset for generic networks (layer %s)" % layer . name ) return network
perform a few cleanup routines on a generic network returns a new netparameter .