Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos in documentation strings for tfjs-layer folder #8376

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tfjs-layers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ys = tf.tensor2d([[1], [3], [5], [7]], [4, 1]);
// Train the model.
await model.fit(xs, ys, {epochs: 500});

// Ater the training, perform inference.
// After the training, perform inference.
const output = model.predict(tf.tensor2d([[5]], [1, 1]));
output.print();
```
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Once the development environment is prepared, execute the build script from the
```

The script will construct a number of Keras models in Python and benchmark their training using the TensorFlow backend. When it is complete, it will bring up a
local HTTP server. Navigate to the local URL spcecified in stdout to bring up
local HTTP server. Navigate to the local URL specified in stdout to bring up
the benchmarks page UI. There will be a button to begin the JS side of the
benchmarks. Clicking the button will run through and time the same models, now
running in the browser.
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/backend/tfjs_backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function sliceAlongLastAxis(
}

/**
* Do slicing along the sepcified axis.
* Do slicing along the specified axis.
* @param array input `tf.Tensor`.
* @param start starting index, inclusive.
* @param size of the slice along the chosen axis.
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/base_callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ export class CallbackConstructorRegistry {
* callbacks for every tf.LayersModel.fit() call afterwards.
*
* @param verbosityLevel Level of verbosity at which the `callbackConstructor`
* is to be reigstered.
* is to be registered.
* @param callbackConstructor A no-arg constructor for `tf.Callback`.
* @throws Error, if the same callbackConstructor has been registered before,
* either at the same or a different `verbosityLevel`.
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/constraints_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describeMathCPU('constraints.get', () => {

describe('Constraints Serialization', () => {
it('Built-ins', () => {
// Test both types of captialization.
// Test both types of capitalization.
const constraints: ConstraintIdentifier[] = [
'maxNorm', 'nonNeg', 'unitNorm', 'minMaxNorm', 'MaxNorm', 'NonNeg',
'UnitNorm', 'MinMaxNorm'
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/engine/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ export abstract class Container extends Layer {
throw new ValueError(
'Container instance unexpectedly contains _trainableWeights.' +
'The trainable weights of a Container are a union of the ' +
'trainable weights of its consituent Layers. Its own ' +
'trainable weights of its constituent Layers. Its own ' +
'_trainableWeights must remain an empty Array.');
}

Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/engine/dataset_fakes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface FakeDatasetArgs {
xShape: Shape|{[name: string]: Shape};

/**
* The shape of the target(s) of a single exapmle.
* The shape of the target(s) of a single example.
*/
yShape: Shape|{[name: string]: Shape};

Expand Down
6 changes: 3 additions & 3 deletions tfjs-layers/src/engine/dataset_fakes_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describeMathCPUAndGPU('FakeNumericDataset', () => {
const dataset = new FakeNumericDataset(
{xShape: [3], yShape: [1], batchSize: 8, numBatches: 5});
for (let k = 0; k < 2; ++k) {
// Run twice to make sure that calling iteartor() multiple times works.
// Run twice to make sure that calling iterator() multiple times works.
const iterator = await dataset.iterator();
for (let i = 0; i < 5; ++i) {
const result = await iterator.next();
Expand All @@ -39,7 +39,7 @@ describeMathCPUAndGPU('FakeNumericDataset', () => {
const dataset = new FakeNumericDataset(
{xShape: [3, 4], yShape: [2], batchSize: 8, numBatches: 5});
for (let k = 0; k < 2; ++k) {
// Run twice to make sure that calling iteartor() multiple times works.
// Run twice to make sure that calling iterator() multiple times works.
const iterator = await dataset.iterator();
for (let i = 0; i < 5; ++i) {
const result = await iterator.next();
Expand All @@ -63,7 +63,7 @@ describeMathCPUAndGPU('FakeNumericDataset', () => {
numBatches: 5
});
for (let k = 0; k < 2; ++k) {
// Run twice to make sure that calling iteartor() multiple times works.
// Run twice to make sure that calling iterator() multiple times works.
const iterator = await dataset.iterator();
for (let i = 0; i < 5; ++i) {
const result = await iterator.next();
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/engine/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export function execute(
}
// NOTE(cais): Unlike intermediate tensors, we don't discard mask
// tensors as we go, because these tensors are sometimes passed over a
// series of mutliple layers, i.e., not obeying the immediate input
// series of multiple layers, i.e., not obeying the immediate input
// relations in the graph. If this becomes a memory-usage concern,
// we can improve this in the future.
internalFeedDict.disposeMasks();
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/engine/topology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ export abstract class Layer extends serialization.Serializable {
// masking not explicitly supported: return null as mask
return null;
}
// if masking is explictly supported, by default
// if masking is explicitly supported, by default
// carry over the input mask
return mask;
}
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/engine/topology_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ describeMathCPUAndGPU('Layer-dispose', () => {
const model = tfl.model({inputs: [input], outputs: [output]});

const result = model.dispose();
// This model, consiting of only an input layer and a reshape layer, does
// This model,consisting of only an input layer and a reshape layer,does
// not have any weights to dispose.
expect(result.numDisposedVariables).toEqual(0);
expect(() => model.predict(zeros([1, 2, 3])))
Expand Down
8 changes: 4 additions & 4 deletions tfjs-layers/src/engine/training.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function checkLossAndTargetCompatibility(
* @param shapes: Expected shapes for the input data, from the model.
* @param checkBatchAxis: Whether the size along the batch axis (i.e., the
* first dimension) will be checked for matching.
* @param exceptionPrefix: Execption prefix message, used in generating error
* @param exceptionPrefix: Exception prefix message, used in generating error
* messages.
* @throws ValueError: on incorrect number of inputs or mismatches in shapes.
*/
Expand Down Expand Up @@ -513,7 +513,7 @@ export class LayersModel extends Container implements tfc.InferenceModel {
// implicit "knowledge" of the outputs it depends on.
metricsTensors: Array<[LossOrMetricFn, number]>;

// User defind metadata (if any).
// User defined metadata (if any).
private userDefinedMetadata: {};

constructor(args: ContainerArgs) {
Expand Down Expand Up @@ -921,7 +921,7 @@ export class LayersModel extends Container implements tfc.InferenceModel {
} else {
throw new ValueError(
`Either the input data should have a defined shape, or ` +
`${stepsName} shoud be specified.`);
`${stepsName} should be specified.`);
}
return numSamples;
}
Expand Down Expand Up @@ -1028,7 +1028,7 @@ export class LayersModel extends Container implements tfc.InferenceModel {
* @param batchSize: integer batch size.
* @param verbose: verbosity model
* @returns: Predictions as `tf.Tensor` (if a single output) or an `Array` of
* `tf.Tensor` (if multipe outputs).
* `tf.Tensor` (if multiple outputs).
*/
private predictLoop(ins: Tensor|Tensor[], batchSize = 32, verbose = false):
Tensor|Tensor[] {
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/engine/training_dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ export async function evaluateDataset<T>(
if (hasBatches) {
console.warn(
'Your dataset iterator ran out of data during evaluateDataset(). ' +
'Interrupting evalution. Make sure that your ' +
'Interrupting evaluation. Make sure that your ' +
'dataset can generate at least `batches` ' +
`batches (in this case, ${args.batches} batches). ` +
'You may need to use the repeat() function when building ' +
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/engine/training_dataset_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ describeMathCPUAndGPU('LayersModel.fitDataset', () => {
expect(numTensors1).toEqual(numTensors0);
});

// Refence Python tf.keras code:
// Reference Python tf.keras code:
//
// ```py
// import numpy as np
Expand Down
11 changes: 6 additions & 5 deletions tfjs-layers/src/engine/training_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ describeMathCPUAndWebGL2('LayersModel.fit long', () => {
it('Return sequences; Fit with metric', async () => {
// The golden values for history used in the assertion below can be obtained
// with the following Python Keras code.
// Ran with Python Keras verion 2.1.2 and TensorFlow (CPU) version
// Ran with Python Keras version 2.1.2 and TensorFlow (CPU) version
// 1.7.0-dev20180226.
// ```python
// import keras
Expand Down Expand Up @@ -500,9 +500,10 @@ describeMathCPUAndWebGL2('LayersModel.fit long', () => {
const dataSize = 16;
const validationSplit = 0.5;
const batchSize = 3;
// So there are 8 examples for train and validation, respectivly. The actual
// batches during training and validation will be 3, 3 and 2. This tests the
// correct averaging of the loss values happens without broadcasting.
// So there are 8 examples for train and validation, respectively.
// The actual batches during training and validation will be 3, 3 and 2.
// This tests the correct averaging of the loss values happens without
// broadcasting.
const outputSize = 2;
const simpleRNN = tfl.layers.simpleRNN({
units: outputSize,
Expand Down Expand Up @@ -2286,7 +2287,7 @@ describeMathGPU('LayersModel.fit: yieldEvery', () => {
yieldEvery + 1, // Should call.
yieldEvery + 1, // Should call.
1,
yieldEvery + 1, // SHould call.
yieldEvery + 1, // Should call.
yieldEvery + 1, // Should call.
1,
1,
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {Sequential, SequentialArgs} from './models';
export {loadLayersModel} from './models';

// TODO(cais): Add doc string to all the public static functions in this
// class; include exectuable JavaScript code snippets where applicable
// class; include executable JavaScript code snippets where applicable
// (b/74074458).

// LayersModel and related factory methods.
Expand Down
4 changes: 2 additions & 2 deletions tfjs-layers/src/exports_layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {Resizing, ResizingArgs} from './layers/preprocessing/image_resizing';
import {RandomWidth, RandomWidthArgs} from './layers/preprocessing/random_width';

// TODO(cais): Add doc string to all the public static functions in this
// class; include exectuable JavaScript code snippets where applicable
// class; include executable JavaScript code snippets where applicable
// (b/74074458).

// Input Layer.
Expand Down Expand Up @@ -1772,7 +1772,7 @@ export function centerCrop(args?: CenterCropArgs) {
* This layer resizes an image input to a target height and width. The input
* should be a 4D (batched) or 3D (unbatched) tensor in `"channels_last"`
* format. Input pixel values can be of any range (e.g. `[0., 1.)` or `[0,
* 255]`) and of interger or floating point dtype. By default, the layer will
* 255]`) and of integer or floating point dtype. By default, the layer will
* output floats.
*
* Arguments:
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/layers/convolutional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export abstract class BaseConv extends Layer {
protected readonly dilationRate: number[];

// Bias-related members are here because all convolution subclasses use the
// same configuration parmeters to control bias. Kernel-related members
// same configuration parameters to control bias. Kernel-related members
// are in subclass `Conv` because some subclasses use different parameters to
// control kernel properties, for instance, `DepthwiseConv2D` uses
// `depthwiseInitializer` instead of `kernelInitializer`.
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/layers/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export class Reshape extends Layer {
if (unknown === null) {
unknown = i;
} else {
throw new ValueError('Can only specifiy one unknown dimension.');
throw new ValueError('Can only specify one unknown dimension.');
}
} else {
known *= dim;
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/layers/core_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ describe('Reshape Layer: Symbolic', () => {
const targetShape: number[] = [null, null];
const flattenLayer = tfl.layers.reshape({targetShape});
expect(() => flattenLayer.apply(symbolicInput))
.toThrowError(/Can only specifiy one unknown dimension/);
.toThrowError(/Can only specify one unknown dimension/);
});

it('One unknown with indivisible size.', () => {
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/layers/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ export class Concatenate extends Merge {
if (mask.length !== inputs.length) {
throw new ValueError(
`Mismatch in the length of mask (${mask.length}) ` +
`and the legnth of inputs (${inputs.length})`);
`and the length of inputs (${inputs.length})`);
}
return tfc.tidy(() => {
let allNullMasks = true;
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/layers/merge_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ describeMathCPU('Deserialize Merge Layers', () => {
});

describeMathCPU('Dot-Layer: Symbolic', () => {
// Example refernce Python Keras code:
// Example reference Python Keras code:
//
// ```py
// import keras
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('TransformerDecoder', () => {
const config = testLayer.getConfig();
const restored = TransformerDecoder.fromConfig(TransformerDecoder, config);

// Initializers don't get serailized with customObjects.
// Initializers don't get serialized with customObjects.
delete ((config['kernelInitializer'] as serialization.ConfigDict
)['config'] as serialization.ConfigDict)['customObjects'];
delete ((config['biasInitializer'] as serialization.ConfigDict
Expand Down Expand Up @@ -167,5 +167,5 @@ describe('TransformerDecoder', () => {
expectTensorsClose(outputCache, noLoopCache);
});

// TODO(pforderique): Test mask propogation once supported.
// TODO(pforderique): Test mask propagation once supported.
});
2 changes: 1 addition & 1 deletion tfjs-layers/src/layers/nlp/models/gpt2/gpt2_causal_lm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export declare interface GPT2CausalLMArgs extends PipelineModelArgs {
}

/**
* An end-to-end GPT2 model for causal langauge modeling.
* An end-to-end GPT2 model for causal language modeling.
*
* A causal language model (LM) predicts the next token based on previous
* tokens. This task setup can be used to train the model unsupervised on
Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/layers/nlp/multihead_attention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ export class MultiHeadAttention extends Layer {

newInputs = [inputs, kwargs['value']].concat(kwargs['key'] ?? []);

// TODO(pforderique): Support mask propogation.
// TODO(pforderique): Support mask propagation.
return super.apply(newInputs, kwargs);
}

Expand Down
2 changes: 1 addition & 1 deletion tfjs-layers/src/layers/normalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export interface LayerNormalizationLayerArgs extends LayerArgs {
axis?: number|number[];

/**
* A small positive float added to variance to avoid divison by zero.
* A small positive float added to variance to avoid division by zero.
* Defaults to 1e-3.
*/
epsilon?: number;
Expand Down
4 changes: 2 additions & 2 deletions tfjs-layers/src/layers/normalization_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ describeMathCPUAndWebGL2('BatchNormalization Layers: Tensor', () => {
const x = tensor2d([[1, 2], [3, 4]], [2, 2]);
expectTensorsClose(layer.apply(x) as Tensor, x, 0.01);
expect(layer.getWeights().length).toEqual(3);
// Firt weight is gamma.
// First weight is gamma.
expectTensorsClose(layer.getWeights()[0], onesLike(layer.getWeights()[0]));
// Second weight is moving mean.
expectTensorsClose(layer.getWeights()[1], zerosLike(layer.getWeights()[1]));
Expand All @@ -366,7 +366,7 @@ describeMathCPUAndWebGL2('BatchNormalization Layers: Tensor', () => {
const x = tensor2d([[1, 2], [3, 4]], [2, 2]);
expectTensorsClose(layer.apply(x) as Tensor, x, 0.01);
expect(layer.getWeights().length).toEqual(3);
// Firt weight is beta.
// First weight is beta.
expectTensorsClose(layer.getWeights()[0], zerosLike(layer.getWeights()[0]));
// Second weight is moving mean.
expectTensorsClose(layer.getWeights()[1], zerosLike(layer.getWeights()[1]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describeMathCPUAndGPU('Resizing Layer', () => {
});

it('Returns a tensor of the correct dtype', () => {
// do a same resizing operation, cheeck tensors dtypes and content
// do a same resizing operation, check tensors dtypes and content
const height = 40;
const width = 60;
const numChannels = 3;
Expand Down
4 changes: 2 additions & 2 deletions tfjs-layers/src/layers/preprocessing/random_height.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type InterpolationType = typeof INTERPOLATION_KEYS[number];
*
* The input should be a 3D (unbatched) or
* 4D (batched) tensor in the `"channels_last"` image data format. Input pixel
* values can be of any range (e.g. `[0., 1.)` or `[0, 255]`) and of interger
* values can be of any range (e.g. `[0., 1.)` or `[0, 255]`) and of integer
* or floating point dtype. By default, the layer will output floats.
*
* tf methods implemented in tfjs: 'bilinear', 'nearest',
Expand All @@ -48,7 +48,7 @@ export class RandomHeight extends BaseRandomLayer {
/** @nocollapse */
static override className = 'RandomHeight';
private readonly factor: number | [number, number];
private readonly interpolation?: InterpolationType; // defualt = 'bilinear
private readonly interpolation?: InterpolationType; // default = 'bilinear
private heightLower: number;
private heightUpper: number;
private imgWidth: number;
Expand Down
4 changes: 2 additions & 2 deletions tfjs-layers/src/layers/preprocessing/random_width.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type InterpolationType = typeof INTERPOLATION_KEYS[number];
*
* The input should be a 3D (unbatched) or
* 4D (batched) tensor in the `"channels_last"` image data format. Input pixel
* values can be of any range (e.g. `[0., 1.)` or `[0, 255]`) and of interger
* values can be of any range (e.g. `[0., 1.)` or `[0, 255]`) and of integer
* or floating point dtype. By default, the layer will output floats.
*
* tf methods implemented in tfjs: 'bilinear', 'nearest',
Expand All @@ -48,7 +48,7 @@ export class RandomWidth extends BaseRandomLayer {
/** @nocollapse */
static override className = 'RandomWidth';
private readonly factor: number | [number, number];
private readonly interpolation?: InterpolationType; // defualt = 'bilinear
private readonly interpolation?: InterpolationType; // default = 'bilinear
private widthLower: number;
private widthUpper: number;
private imgHeight: number;
Expand Down
Loading