return tf.tidy(function () { var batchSize = boxPredictions.shape[0]; var boxes = decodeBoxesLayer(tf.reshape(tf.tile(params.extra_dim, [batchSize, 1, 1]), [-1, 4]), tf.reshape(boxPredictions, [-1, 4])); boxes = tf.reshape(boxes, [batchSize, (boxes.shape[0] / batchSize), 4]); var scoresAndClasses = tf.sigmoid(tf.slice(classPredictions, [0, 0, 1], [-1, -1, -1])); var scores = tf.slice(scoresAndClasses, [0, 0, 0], [-1, -1, 1]); scores = tf.reshape(scores, [batchSize, scores.shape[1]]); var boxesByBatch = tf.unstack(boxes); var scoresByBatch = tf.unstack(scores); return { boxes: boxesByBatch, scores: scoresByBatch }; });
function sigmoid(x) { return tfc.sigmoid(x); }