MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / indexToOneHot

Function indexToOneHot

mnist-transfer-cnn/util.js:75–81  ·  view source on GitHub ↗
(index, numClasses)

Source from the content-addressed store, hash-verified

73}
74
75export function indexToOneHot(index, numClasses) {
76 const oneHot = [];
77 for (let i = 0; i < numClasses; ++i) {
78 oneHot.push(i === index ? 1 : 0);
79 }
80 return oneHot;
81}
82
83export function convertDataToTensors(data, numClasses) {
84 const numExamples = data.length;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected