Set the mode of DistModel to "predict". In "predict" mode, executing ``__call__`` returns a dict that contains the outputs of the model.
(self)
| 3079 | paddle.disable_static() |
| 3080 | |
| 3081 | def predict(self) -> None: |
| 3082 | """ |
| 3083 | Set the mode of DistModel to "predict". In "predict" mode, |
| 3084 | executing ``__call__`` returns a dict that contains the |
| 3085 | outputs of the model. |
| 3086 | """ |
| 3087 | if not self._engine._has_prepared["predict"]: |
| 3088 | self._engine.prepare( |
| 3089 | copy.deepcopy(self._engine._inputs_spec), |
| 3090 | None, |
| 3091 | mode="predict", |
| 3092 | init_parameters=False, |
| 3093 | ) |
| 3094 | |
| 3095 | self._mode = "predict" |
| 3096 | self._engine.to_mode("predict") |
| 3097 | paddle.disable_static() |
| 3098 | |
| 3099 | def __validate_mode(self, mode): |
| 3100 | if mode is None and self._mode is None: |