(self, specs, shapes=None, dtypes=None, is_input=False)
| 2992 | return summary(self.network, _input_size, dtypes=dtype) |
| 2993 | |
| 2994 | def _verify_spec(self, specs, shapes=None, dtypes=None, is_input=False): |
| 2995 | out_specs = [] |
| 2996 | |
| 2997 | if specs is None: |
| 2998 | # Note(Aurelius84): If not specific specs of `Input`, using argument names of `forward` function |
| 2999 | # to generate `Input`. But how can we know the actual shape of each input tensor? |
| 3000 | |
| 3001 | if is_input: |
| 3002 | arg_names = extract_args(self.network.forward)[1:] |
| 3003 | # While Saving inference model in dygraph, and providing inputs only in running. |
| 3004 | if ( |
| 3005 | shapes is not None |
| 3006 | and dtypes is not None |
| 3007 | and in_dynamic_mode() |
| 3008 | ): |
| 3009 | out_specs = [ |
| 3010 | Input(name=n, dtype=dtypes[i], shape=shapes[i]) |
| 3011 | for i, n in enumerate(arg_names) |
| 3012 | ] |
| 3013 | else: |
| 3014 | out_specs = [Input(name=n, shape=[None]) for n in arg_names] |
| 3015 | else: |
| 3016 | out_specs = to_list(specs) |
| 3017 | elif isinstance(specs, dict): |
| 3018 | assert is_input is False |
| 3019 | out_specs = [ |
| 3020 | specs[n] |
| 3021 | for n in extract_args(self.network.forward) |
| 3022 | if n != 'self' |
| 3023 | ] |
| 3024 | else: |
| 3025 | out_specs = to_list(specs) |
| 3026 | # Note: checks each element has specified `name`. |
| 3027 | if out_specs is not None: |
| 3028 | for i, spec in enumerate(out_specs): |
| 3029 | assert isinstance(spec, Input) |
| 3030 | if spec.name is None: |
| 3031 | raise ValueError( |
| 3032 | f"Requires Input[{i}].name != None, but receive `None` with {spec}." |
| 3033 | ) |
| 3034 | |
| 3035 | return out_specs |
| 3036 | |
| 3037 | def _reset_metrics(self): |
| 3038 | for metric in self._metrics: |
no test coverage detected