MCPcopy
hub / github.com/tensorflow/tfjs / assertLabelsMatchShape

Function assertLabelsMatchShape

tfjs-vis/src/render/heatmap.ts:285–301  ·  view source on GitHub ↗
(
    inputValues: number[][]|tf.Tensor2D, labels: string[], dimension: 0|1)

Source from the content-addressed store, hash-verified

283}
284
285function assertLabelsMatchShape(
286 inputValues: number[][]|tf.Tensor2D, labels: string[], dimension: 0|1) {
287 const shape = inputValues instanceof tf.Tensor ?
288 inputValues.shape :
289 [inputValues.length, inputValues[0].length];
290 if (dimension === 0) {
291 assert(
292 shape[0] === labels.length,
293 `Length of xTickLabels (${labels.length}) must match number of rows` +
294 ` (${shape[0]})`);
295 } else if (dimension === 1) {
296 assert(
297 shape[1] === labels.length,
298 `Length of yTickLabels (${
299 labels.length}) must match number of columns (${shape[1]})`);
300 }
301}
302
303const defaultOpts: HeatmapOptions = {
304 xLabel: null,

Callers 1

heatmapFunction · 0.85

Calls 1

assertFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…