UNPKG

1.68 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2020 Google LLC. All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 * =============================================================================
16 */
17import { Tensor } from '../tensor';
18import { TensorLike } from '../types';
19/**
20 * Creates a one-hot `tf.Tensor`. The locations represented by `indices` take
21 * value `onValue` (defaults to 1), while all other locations take value
22 * `offValue` (defaults to 0). If `indices` is rank `R`, the output has rank
23 * `R+1` with the last axis of size `depth`.
24 *
25 * ```js
26 * tf.oneHot(tf.tensor1d([0, 1], 'int32'), 3).print();
27 * ```
28 *
29 * @param indices `tf.Tensor` of indices with dtype `int32`.
30 * @param depth The depth of the one hot dimension.
31 * @param onValue A number used to fill in the output when the index matches
32 * the location.
33 * @param offValue A number used to fill in the output when the index does
34 * not match the location.
35 *
36 * @doc {heading: 'Tensors', subheading: 'Creation'}
37 */
38declare function oneHot_(indices: Tensor | TensorLike, depth: number, onValue?: number, offValue?: number): Tensor;
39export declare const oneHot: typeof oneHot_;
40export {};