(self, inputs)
| 2138 | return values |
| 2139 | |
| 2140 | def _maybe_build(self, inputs): |
| 2141 | # Check input assumptions set before layer building, e.g. input rank. |
| 2142 | if not self.built: |
| 2143 | input_spec.assert_input_compatibility( |
| 2144 | self.input_spec, inputs, self.name) |
| 2145 | input_list = nest.flatten(inputs) |
| 2146 | if input_list and self._dtype_policy.compute_dtype is None: |
| 2147 | try: |
| 2148 | dtype = input_list[0].dtype.base_dtype.name |
| 2149 | except AttributeError: |
| 2150 | pass |
| 2151 | else: |
| 2152 | self._dtype_policy = policy.with_input_dtype(self._dtype_policy, |
| 2153 | dtype) |
| 2154 | input_shapes = None |
| 2155 | if all(hasattr(x, 'shape') for x in input_list): |
| 2156 | input_shapes = nest.map_structure(lambda x: x.shape, inputs) |
| 2157 | # Only call `build` if the user has manually overridden the build method. |
| 2158 | if not hasattr(self.build, '_is_default'): |
| 2159 | # Any setup work performed only once should happen in an `init_scope` |
| 2160 | # to avoid creating symbolic Tensors that will later pollute any eager |
| 2161 | # operations. |
| 2162 | with tf_utils.maybe_init_scope(self): |
| 2163 | self.build(input_shapes) |
| 2164 | # We must set self.built since user defined build functions are not |
| 2165 | # constrained to set self.built. |
| 2166 | self.built = True |
| 2167 | |
| 2168 | # Optionally load weight values specified at layer instantiation. |
| 2169 | if getattr(self, '_initial_weights', None) is not None: |
| 2170 | self.set_weights(self._initial_weights) |
| 2171 | self._initial_weights = None |
| 2172 | |
| 2173 | def _symbolic_call(self, inputs): |
| 2174 | input_shapes = nest.map_structure(lambda x: x.shape, inputs) |
no test coverage detected