def generate_missing_names(self): name_generator = utils.NameGenerator(used_names=set(t.name for t in self.tensors if t.name)) for t in self.tensors: if not t.name: if self.input_ids is not None and t in self.inputs: t.name = name_generator.get_new_name(self.input_ids[list(self.inputs).index(t)]) elif self.output_ids is not None and t in self.outputs: t.name = name_generator.get_new_name(self.output_ids[list(self.outputs).index(t)]) elif t.is_variable: t.name = name_generator.get_new_name('variable') elif t.is_constant: t.name = name_generator.get_new_name('constant') elif t.producer is None: t.name = name_generator.get_new_name('external') else: t.name = name_generator.get_new_name(t.producer.name) label_generator = utils.NameGenerator(used_names=set(t.label for t in self.tensors if t.label)) for t in self.tensors: if t.is_variable and not t.label: t.label = label_generator.get_new_name('variable') if not self.name: self.name = "network"
def _generate_names(graph): ng = utils.NameGenerator() names = {} for op in graph.operations: new_name = ng.get_new_name(op.name) names[op] = new_name for i, tensor in enumerate(op.outputs): if i == 0: names[tensor] = new_name else: names[tensor] = new_name + ':' + str(i) for tensor in graph.tensors: if tensor.producer is None: if tensor.data is None: if tensor in graph.inputs and graph.input_ids: names[tensor] = ng.get_new_name(graph.input_ids[graph.inputs.index(tensor)]) else: names[tensor] = ng.get_new_name('Placeholder') elif isinstance(tensor.data, np.ndarray): if tensor.label: names[tensor] = ng.get_new_name(tensor.label) else: names[tensor] = ng.get_new_name('Variable') else: names[tensor] = ng.get_new_name('Const') return names
def generate_missing_names(self): name_generator = utils.NameGenerator(used_names=set( t.name for t in self.tensors if t.name)) for t in self.tensors: if not t.name: if t.is_variable: t.name = name_generator.get_new_name('variable') elif t.is_constant: t.name = name_generator.get_new_name('constant') else: assert t.producer t.name = name_generator.get_new_name(t.producer.name) label_generator = utils.NameGenerator(used_names=set( op.label for op in self.operations if op.label)) for op in self.operations: if not op.label: op.label = label_generator.get_new_name(op.outputs[0].name)
def __init__(self, enable_default_conversion=False, custom_converter_by_op_name=None): converters = {} converters.update(_StandardConverters) if custom_converter_by_op_name is not None: converters.update(custom_converter_by_op_name) default_op_converter = convert_default if enable_default_conversion else None super(Converter, self).__init__(op_converter_by_name=converters, default_op_converter=default_op_converter) self.displayed_warnings = set() self.name_generator = utils.NameGenerator()
def generate_missing_names(self): # type: (TFGraph)->None # assert self.is_unique ng = utils.NameGenerator() for t in self.tensors: if t.name and ng.is_available(t.name): t.name = ng.get_new_name(t.name) elif t.producer: t.name = ng.get_new_name(t.producer.name.split('.')[-1]) elif t.is_variable: t.name = ng.get_new_name("variable") elif t.is_constant: t.name = ng.get_new_name("constant") else: t.name = ng.get_new_name("placeholder")
def generate_missing_names(self): # type: ()->None # assert self.is_unique ng = utils.NameGenerator(used_names=set(t.name for t in self.tensors if t.name)) for t in self.tensors: if t.name: pass elif self.input_ids is not None and t in self.inputs: t.name = ng.get_new_name(self.input_ids[list(self.inputs).index(t)]) elif self.output_ids is not None and t in self.outputs: t.name = ng.get_new_name(self.output_ids[list(self.outputs).index(t)]) elif t.is_variable: t.name = ng.get_new_name('variable') elif t.is_constant: t.name = ng.get_new_name('constant') elif t.producer is None: t.name = ng.get_new_name('external') else: t.name = ng.get_new_name(t.producer.name.split('.')[-1])