(
inputs: Tensor[], targets: Tensor[], weights?: Tensor[])
| 192 | * @throws ValueError: in case of incorrectly formatted data. |
| 193 | */ |
| 194 | export function checkArrayLengths( |
| 195 | inputs: Tensor[], targets: Tensor[], weights?: Tensor[]) { |
| 196 | const setX = unique(inputs.map(input => input.shape[0])); |
| 197 | setX.sort(); |
| 198 | const setY = unique(targets.map(target => target.shape[0])); |
| 199 | setY.sort(); |
| 200 | // TODO(cais): Check `weights` as well. |
| 201 | if (setX.length > 1) { |
| 202 | throw new ValueError( |
| 203 | `All input Tensors (x) should have the same number of samples. ` + |
| 204 | `Got array shapes: ` + |
| 205 | `${JSON.stringify(inputs.map(input => input.shape))}`); |
| 206 | } |
| 207 | if (setY.length > 1) { |
| 208 | throw new ValueError( |
| 209 | `All target Tensors (y) should have the same number of samples. ` + |
| 210 | `Got array shapes: ` + |
| 211 | `${JSON.stringify(targets.map(target => target.shape))}`); |
| 212 | } |
| 213 | if (setX.length > 0 && setY.length > 0 && !util.arraysEqual(setX, setY)) { |
| 214 | throw new ValueError( |
| 215 | `Input Tensors should have the same number of samples as target ` + |
| 216 | `Tensors. Found ${setX[0]} input sample(s) and ${setY[0]} target ` + |
| 217 | `sample(s).`); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Validation on the compatibility of targes and loss functions. |
no test coverage detected
searching dependent graphs…