From 32cface3c444684f448c408cfe628abaf912e90a Mon Sep 17 00:00:00 2001 From: Yannick Assogba Date: Tue, 5 Jun 2018 15:20:01 -0400 Subject: [PATCH] Fix documentation issues DOC * Update docs for fromPixels * Improve docs for tidy --- src/ops/array_ops.ts | 12 ++++++------ src/tracking.ts | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ops/array_ops.ts b/src/ops/array_ops.ts index 13f50fd908..d47d3cb1f2 100644 --- a/src/ops/array_ops.ts +++ b/src/ops/array_ops.ts @@ -280,8 +280,7 @@ export class ArrayOps { } const inferredShape = util.inferShape(values); if (inferredShape.length !== 5 && inferredShape.length !== 1) { - throw new Error( - 'tensor5d() requires values to be \ + throw new Error('tensor5d() requires values to be \ number[][][][][] or flat/TypedArray'); } if (inferredShape.length === 1 && shape == null) { @@ -674,10 +673,11 @@ export class ArrayOps { * tf.fromPixels(image).print(); * ``` * - * @param pixels The input image to construct the tensor from. - * @param numChannels The number of channels of the output tensor. The - * supported image types are all 4-channel by default, a numChannels value - * less than 4 allows you to ignore channels. + * @param pixels The input image to construct the tensor from. The + * supported image types are all 4-channel. + * @param numChannels The number of channels of the output tensor. A + * numChannels value less than 4 allows you to ignore channels. Defaults to + * 3 (ignores alpha channel of input image). */ @doc({heading: 'Tensors', subheading: 'Creation'}) @operation diff --git a/src/tracking.ts b/src/tracking.ts index 639b919b13..87640da6ea 100644 --- a/src/tracking.ts +++ b/src/tracking.ts @@ -24,8 +24,8 @@ import {extractTensorsFromAny} from './util'; export class Tracking { /** - * Executes the provided function `f` and after it is executed, cleans up all - * intermediate tensors allocated by `f` except those returned by `f`. + * Executes the provided function `fn` and after it is executed, cleans up all + * intermediate tensors allocated by `fn` except those returned by `fn`. * `f` must not return a Promise (async functions not allowed). * The returned result can be a complex object, however tidy only walks the * top-level properties (depth 1) of that object to search for tensors, or @@ -61,11 +61,13 @@ export class Tracking { * If debug mode is on, the timing and the memory usage of the function * will be tracked and displayed on the console using the provided name. * @param fn The function to execute. - * @param gradMode If true, starts a tape and doesn't dispose tensors. */ @doc({heading: 'Performance', subheading: 'Memory'}) static tidy( nameOrFn: string|ScopeFn, fn?: ScopeFn, gradMode = false): T { + // gradMode Primarily for internal use during backprop + // If true, will start a tape if it is the outermost tidy. + let name = null; if (fn == null) { // Called with only 1 argument.