UNPKG

1.76 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 { Tensor1D, Tensor2D } from '../tensor';
18import { TensorLike } from '../types';
19/**
20 * Creates a `tf.Tensor` with values drawn from a multinomial distribution.
21 *
22 * ```js
23 * const probs = tf.tensor([.75, .25]);
24 * tf.multinomial(probs, 3).print();
25 * ```
26 *
27 * @param logits 1D array with unnormalized log-probabilities, or
28 * 2D array of shape `[batchSize, numOutcomes]`. See the `normalized`
29 * parameter.
30 * @param numSamples Number of samples to draw for each row slice.
31 * @param seed The seed number.
32 * @param normalized Whether the provided `logits` are normalized true
33 * probabilities (sum to 1). Defaults to false.
34 * @return 1D array of shape `[numSamples]`, or 2D array of shape
35 * `[batchSize, numSamples]`, depending on the rank of the input.
36 *
37 * @doc {heading: 'Tensors', subheading: 'Random'}
38 */
39declare function multinomial_(logits: Tensor1D | Tensor2D | TensorLike, numSamples: number, seed?: number, normalized?: boolean): Tensor1D | Tensor2D;
40export declare const multinomial: typeof multinomial_;
41export {};