Evaluation output (always contains labels), to be used to compute metrics. Parameters: predictions (`np.ndarray`): Predictions of the model. label_ids (`np.ndarray`): Targets to be matched. inputs (`np.ndarray`, *optional*):
| 150 | |
| 151 | |
| 152 | class EvalPrediction: |
| 153 | """ |
| 154 | Evaluation output (always contains labels), to be used to compute metrics. |
| 155 | |
| 156 | Parameters: |
| 157 | predictions (`np.ndarray`): Predictions of the model. |
| 158 | label_ids (`np.ndarray`): Targets to be matched. |
| 159 | inputs (`np.ndarray`, *optional*): |
| 160 | """ |
| 161 | |
| 162 | def __init__( |
| 163 | self, |
| 164 | predictions: Union[np.ndarray, Tuple[np.ndarray]], |
| 165 | label_ids: Union[np.ndarray, Tuple[np.ndarray]], |
| 166 | inputs: Optional[Union[np.ndarray, Tuple[np.ndarray]]] = None, |
| 167 | ): |
| 168 | self.predictions = predictions |
| 169 | self.label_ids = label_ids |
| 170 | self.inputs = inputs |
| 171 | |
| 172 | def __iter__(self): |
| 173 | if self.inputs is not None: |
| 174 | return iter((self.predictions, self.label_ids, self.inputs)) |
| 175 | else: |
| 176 | return iter((self.predictions, self.label_ids)) |
| 177 | |
| 178 | def __getitem__(self, idx): |
| 179 | if idx < 0 or idx > 2: |
| 180 | raise IndexError("tuple index out of range") |
| 181 | if idx == 2 and self.inputs is None: |
| 182 | raise IndexError("tuple index out of range") |
| 183 | if idx == 0: |
| 184 | return self.predictions |
| 185 | elif idx == 1: |
| 186 | return self.label_ids |
| 187 | elif idx == 2: |
| 188 | return self.inputs |
| 189 | |
| 190 | |
| 191 | class EvalLoopOutput(NamedTuple): |
no outgoing calls
no test coverage detected