def _finalize_name(self, parent_network): if not self._name: # Were were not passed a name explicitly (or it was blank), so this is an # anonymous Network. We make up a unique name. if parent_network: avoid_names = parent_network._owned_layers name_uid_map = parent_network._sub_layer_name_uids else: name_uid_map = base._get_default_graph_uid_map() # Figure out which names we have to avoid based on which variable scope # we're nested in. strip_name = self._default_parent_variable_scope.name if strip_name: strip_name += "/" def _strip_on_init_scope(name): if name.startswith(strip_name): return name[len(strip_name):] else: return None avoid_names = set( _strip_on_init_scope(name) for name in self._variable_scope_counts_on_init.keys() if name) self._name, self._base_name = self._make_unique_name( name_uid_map=name_uid_map, avoid_names=avoid_names, namespace=self._default_parent_variable_scope.name, zero_based=True) if self._first_parent is None or (self._first_parent # False = no parent and self._first_parent() is None): # Save a pointer to the parent Network so that we can later check that the # scope name we get is correct. if not parent_network: self._first_parent = parent_network else: self._first_parent = weakref.ref(parent_network)
def _finalize_name(self, parent_network): if not self._name: # Were were not passed a name explicitly (or it was blank), so this is an # anonymous Network. We make up a unique name. if parent_network: avoid_names = parent_network._owned_layers name_uid_map = parent_network._sub_layer_name_uids else: name_uid_map = base._get_default_graph_uid_map() # Figure out which names we have to avoid based on which variable scope # we're nested in. strip_name = self._default_parent_variable_scope.name if strip_name: strip_name += "/" def _strip_on_init_scope(name): if name.startswith(strip_name): return name[len(strip_name):] else: return None avoid_names = set( _strip_on_init_scope(name) for name in self._variable_scope_counts_on_init.keys() if name) self._name, self._base_name = self._make_unique_name( name_uid_map=name_uid_map, avoid_names=avoid_names, namespace=self._default_parent_variable_scope.name) if self._first_parent is None or (self._first_parent # False = no parent and self._first_parent() is None): # Save a pointer to the parent Network so that we can later check that the # scope name we get is correct. if not parent_network: self._first_parent = parent_network else: self._first_parent = weakref.ref(parent_network)
def _finalize_name(self, parent_network): if not self._name: if not parent_network: name_uid_map = base._get_default_graph_uid_map() else: name_uid_map = parent_network._sub_layer_name_uids # Were were not passed a name explicitly (or it was blank), so this is an # anonymous Network. We make up a unique name. if parent_network: avoid_names = parent_network._owned_layers else: avoid_names = None self._name, self._base_name = self._make_unique_name( name_uid_map=name_uid_map, avoid_names=avoid_names) if self._first_parent is None or (self._first_parent # False = no parent and self._first_parent() is None): # Save a pointer to the parent Network so that we can later check that the # scope name we get is correct. if not parent_network: self._first_parent = parent_network else: self._first_parent = weakref.ref(parent_network)
def _finalize_name(self, parent_network): if not self._name: if not parent_network: name_uid_map = base._get_default_graph_uid_map() else: name_uid_map = parent_network._sub_layer_name_uids # Were were not passed a name explicitly (or it was blank), so this is an # anonymous Network. We make up a unique name. if parent_network: avoid_names = parent_network._owned_layers else: avoid_names = None self._name, self._base_name = self._make_unique_name( name_uid_map=name_uid_map, avoid_names=avoid_names) if self._first_parent is None or (self._first_parent # False = no parent and self._first_parent() is None): # Save a pointer to the parent Network so that we can later check that the # scope name we get is correct. if not parent_network: self._first_parent = parent_network else: self._first_parent = weakref.ref(parent_network)