(self, name=None, **kwargs)
| 183 | # (in which case less strict assertions may be substituted if necessary). |
| 184 | @trackable.no_automatic_dependency_tracking |
| 185 | def _base_init(self, name=None, **kwargs): |
| 186 | # The following are implemented as property functions: |
| 187 | # self.trainable_weights |
| 188 | # self.non_trainable_weights |
| 189 | # self.input_spec |
| 190 | # self.losses |
| 191 | # self.updates |
| 192 | |
| 193 | generic_utils.validate_kwargs(kwargs, {'trainable', 'dtype', 'dynamic', |
| 194 | 'autocast'}) |
| 195 | |
| 196 | # Object to store all thread local layer properties. |
| 197 | self._thread_local = threading.local() |
| 198 | |
| 199 | self._init_set_name(name, zero_based=True) |
| 200 | self._activity_regularizer = None |
| 201 | # This acts just like the `trainable` attribute of any layer instance. |
| 202 | self._trainable = kwargs.get('trainable', True) |
| 203 | # This attribute has no effect if the model is created using the Functional |
| 204 | # API. Instead, `model.dynamic` is determined based on the internal layers. |
| 205 | self._dynamic = kwargs.get('dynamic', False) |
| 206 | self._is_compiled = False |
| 207 | self._layers = [] |
| 208 | |
| 209 | # This is True for Sequential networks and Functional networks. |
| 210 | self._compute_output_and_mask_jointly = False |
| 211 | |
| 212 | self.supports_masking = False |
| 213 | if not hasattr(self, 'optimizer'): |
| 214 | # Don't reset optimizer if already set. |
| 215 | self.optimizer = None |
| 216 | |
| 217 | # Private attributes to implement compatibility with Layer. |
| 218 | self._maybe_create_attribute('_trainable_weights', []) |
| 219 | self._maybe_create_attribute('_non_trainable_weights', []) |
| 220 | self._updates = [] # Used in symbolic mode only. |
| 221 | self._losses = [] |
| 222 | self._callable_losses = [] |
| 223 | # A list of metric instances corresponding to the symbolic metric tensors |
| 224 | # added using the `add_metric` API. |
| 225 | self._metrics = [] |
| 226 | self._scope = None # Never used. |
| 227 | self._reuse = None # Never used. |
| 228 | if context.executing_eagerly(): |
| 229 | self._graph = None |
| 230 | else: |
| 231 | self._graph = ops.get_default_graph() # Used in symbolic mode only. |
| 232 | |
| 233 | # Both graph and subclassed networks have a dtype policy. For graph |
| 234 | # networks, the policy's compute and variable dtypes are ignored, but other |
| 235 | # fields, like the loss scale, are used by Models. For subclassed networks, |
| 236 | # the compute and variable dtypes are used as like any ordinary layer. |
| 237 | self._set_dtype_policy(kwargs.get('dtype', None)) |
| 238 | |
| 239 | # All layers in order of horizontal graph traversal. |
| 240 | # Entries are unique. Includes input and output layers. |
| 241 | self._maybe_create_attribute('_layers', []) |
| 242 |
no test coverage detected