Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const [x, y, auxY] = tf.tidy(() => {
const imageBatch = xTrain.slice(batchStart, batchSize);
const labelBatch = yTrain.slice(batchStart, batchSize).asType('float32');
// Latent vectors.
let zVectors = tf.randomUniform([batchSize, latentSize], -1, 1);
let sampledLabels =
tf.randomUniform([batchSize, 1], 0, NUM_CLASSES, 'int32')
.asType('float32');
const generatedImages =
generator.predict([zVectors, sampledLabels], {batchSize: batchSize});
const x = tf.concat([imageBatch, generatedImages], 0);
const y = tf.tidy(
() => tf.concat(
[tf.ones([batchSize, 1]).mul(SOFT_ONE), tf.zeros([batchSize, 1])]));
const auxY = tf.concat([labelBatch, sampledLabels], 0);
return [x, y, auxY];
});
// Latent vectors.
let zVectors = tf.randomUniform([batchSize, latentSize], -1, 1);
let sampledLabels =
tf.randomUniform([batchSize, 1], 0, NUM_CLASSES, 'int32')
.asType('float32');
const generatedImages =
generator.predict([zVectors, sampledLabels], {batchSize: batchSize});
const x = tf.concat([imageBatch, generatedImages], 0);
const y = tf.tidy(
() => tf.concat(
[tf.ones([batchSize, 1]).mul(SOFT_ONE), tf.zeros([batchSize, 1])]));
const auxY = tf.concat([labelBatch, sampledLabels], 0);
return [x, y, auxY];
});