Skip to content

Commit

Permalink
Revert "Categoryencoding (#12)" (#14)
Browse files Browse the repository at this point in the history
This reverts commit 2bb58dc.
  • Loading branch information
AdamLang96 committed Sep 23, 2022
1 parent 2bb58dc commit aa5338f
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 439 deletions.
43 changes: 1 addition & 42 deletions tfjs-layers/src/exports_layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {AveragePooling1D, AveragePooling2D, AveragePooling3D, GlobalAveragePooli
import {GRU, GRUCell, GRUCellLayerArgs, GRULayerArgs, LSTM, LSTMCell, LSTMCellLayerArgs, LSTMLayerArgs, RNN, RNNCell, RNNLayerArgs, SimpleRNN, SimpleRNNCell, SimpleRNNCellLayerArgs, SimpleRNNLayerArgs, StackedRNNCells, StackedRNNCellsArgs} from './layers/recurrent';
import {Bidirectional, BidirectionalLayerArgs, TimeDistributed, WrapperLayerArgs} from './layers/wrappers';
import { Rescaling, RescalingArgs } from './layers/preprocessing/image_preprocessing';
import { CategoryEncoding, CategoryEncodingArgs } from './layers/preprocessing/category_encoding';

// TODO(cais): Add doc string to all the public static functions in this
// class; include exectuable JavaScript code snippets where applicable
// (b/74074458).
Expand Down Expand Up @@ -1729,44 +1729,3 @@ export function masking(args?: MaskingArgs) {
export function rescaling(args?: RescalingArgs) {
return new Rescaling(args);
}

/**
* A preprocessing layer which encodes integer features.
*
* This layer provides options for condensing data into a categorical encoding
* when the total number of tokens are known in advance. It accepts integer
* values as inputs, and it outputs a dense or sparse representation of those
* inputs.
*
* Arguments:
*
* numTokens: The total number of tokens the layer should support. All
* inputs to the layer must integers in the range `0 <= value <
* num_tokens`, or an error will be thrown.
*
* outputMode: Specification for the output of the layer.
* Defaults to `"multiHot". Values can be "oneHot", "multiHot" or
* "count", configuring the layer as follows:
*
* oneHot: Encodes each individual element in the input into an
* array of numTokens size, containing a 1 at the element index. If
* the last dimension is size 1, will encode on that dimension. If the
* last dimension is not size 1, will append a new dimension for the
* encoded output.
*
* multiHot: Encodes each sample in the input into a single array
* of `num_tokens` size, containing a 1 for each vocabulary term
* present in the sample. Treats the last dimension as the sample
* dimension, if input shape is `(..., sample_length)`, output shape
* will be `(..., numTokens)`.
*
* count: Like "multiHot", but the int array contains a count of
* the number of times the token at that index appeared in the sample.
*
* For all output modes, currently only output up to rank 2 is supported.
*
* @doc {heading: 'Layers', subheading: 'CategoryEncoding', namespace: 'layers'}
*/
export function categoryEncoding(args: CategoryEncodingArgs) {
return new CategoryEncoding(args);
}
116 changes: 0 additions & 116 deletions tfjs-layers/src/layers/preprocessing/category_encoding.ts

This file was deleted.

140 changes: 0 additions & 140 deletions tfjs-layers/src/layers/preprocessing/category_encoding_test.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export declare interface RescalingArgs extends LayerArgs {
*
* This rescales images by a scaling and offset factor
*/

export class Rescaling extends Layer {
/** @nocollapse */
static className = 'Rescaling';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ describeMathCPUAndGPU('Rescaling Layer', () => {
const expectedOutputTensor = add(mul(intTensor, scale), offset);
const scalingLayer = new Rescaling({scale, offset});
const outputTensor = scalingLayer.apply(intTensor) as Tensor;
expect(outputTensor.dtype).toBe('float32');
expectTensorsClose(outputTensor, expectedOutputTensor);
expect(outputTensor.dtype).toBe('float32');
expectTensorsClose(outputTensor, expectedOutputTensor);
});

it('Config holds correct name', () => {
const scale = 1.0 / 127.5;
const offset = -1.0;
const scalingLayer = new Rescaling({scale, offset, name: 'Rescaling'});
const config = scalingLayer.getConfig();
expect(config.name).toEqual('Rescaling');
expect(config.name).toEqual('Rescaling');
});

});
Loading

0 comments on commit aa5338f

Please sign in to comment.