1// This file is MACHINE GENERATED! Do not edit.
2
3#ifndef TENSORFLOW_CC_OPS_RANDOM_OPS_H_
4#define TENSORFLOW_CC_OPS_RANDOM_OPS_H_
5
6// This file is MACHINE GENERATED! Do not edit.
7
8#include "tensorflow/cc/framework/ops.h"
9#include "tensorflow/cc/framework/scope.h"
10#include "tensorflow/core/framework/tensor.h"
11#include "tensorflow/core/framework/tensor_shape.h"
12#include "tensorflow/core/framework/types.h"
13#include "tensorflow/core/lib/gtl/array_slice.h"
14
15namespace tensorflow {
16namespace ops {
17
18/// @defgroup random_ops Random Ops
19/// @{
20
21/// Draws samples from a multinomial distribution.
22///
23/// Args:
24/// * scope: A Scope object
25/// * logits: 2-D Tensor with shape `[batch_size, num_classes]`. Each slice `[i, :]`
26/// represents the unnormalized log probabilities for all classes.
27/// * num_samples: 0-D. Number of independent samples to draw for each row slice.
28///
29/// Optional attributes (see `Attrs`):
30/// * seed: If either seed or seed2 is set to be non-zero, the internal random number
31/// generator is seeded by the given seed. Otherwise, a random seed is used.
32/// * seed2: A second seed to avoid seed collision.
33///
34/// Returns:
35/// * `Output`: 2-D Tensor with shape `[batch_size, num_samples]`. Each slice `[i, :]`
36/// contains the drawn class labels with range `[0, num_classes)`.
37class Multinomial {
38 public:
39 /// Optional attribute setters for Multinomial
40 struct Attrs {
41 /// If either seed or seed2 is set to be non-zero, the internal random number
42 /// generator is seeded by the given seed. Otherwise, a random seed is used.
43 ///
44 /// Defaults to 0
45 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
46 Attrs ret = *this;
47 ret.seed_ = x;
48 return ret;
49 }
50
51 /// A second seed to avoid seed collision.
52 ///
53 /// Defaults to 0
54 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
55 Attrs ret = *this;
56 ret.seed2_ = x;
57 return ret;
58 }
59
60 /// Defaults to DT_INT64
61 TF_MUST_USE_RESULT Attrs OutputDtype(DataType x) {
62 Attrs ret = *this;
63 ret.output_dtype_ = x;
64 return ret;
65 }
66
67 int64 seed_ = 0;
68 int64 seed2_ = 0;
69 DataType output_dtype_ = DT_INT64;
70 };
71 Multinomial(const ::tensorflow::Scope& scope, ::tensorflow::Input logits,
72 ::tensorflow::Input num_samples);
73 Multinomial(const ::tensorflow::Scope& scope, ::tensorflow::Input logits,
74 ::tensorflow::Input num_samples, const Multinomial::Attrs& attrs);
75 operator ::tensorflow::Output() const { return output; }
76 operator ::tensorflow::Input() const { return output; }
77 ::tensorflow::Node* node() const { return output.node(); }
78
79 static Attrs Seed(int64 x) {
80 return Attrs().Seed(x);
81 }
82 static Attrs Seed2(int64 x) {
83 return Attrs().Seed2(x);
84 }
85 static Attrs OutputDtype(DataType x) {
86 return Attrs().OutputDtype(x);
87 }
88
89 Operation operation;
90 ::tensorflow::Output output;
91};
92
93/// Outputs random values from a normal distribution. The parameters may each be a
94///
95/// scalar which applies to the entire output, or a vector of length shape[0] which
96/// stores the parameters for each batch.
97///
98/// Args:
99/// * scope: A Scope object
100/// * shape: The shape of the output tensor. Batches are indexed by the 0th dimension.
101/// * means: The mean parameter of each batch.
102/// * stdevs: The standard deviation parameter of each batch. Must be greater than 0.
103/// * minvals: The minimum cutoff. May be -infinity.
104/// * maxvals: The maximum cutoff. May be +infinity, and must be more than the minval
105/// for each batch.
106///
107/// Optional attributes (see `Attrs`):
108/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
109/// generator is seeded by the given seed. Otherwise, it is seeded by a
110/// random seed.
111/// * seed2: A second seed to avoid seed collision.
112///
113/// Returns:
114/// * `Output`: A matrix of shape num_batches x samples_per_batch, filled with random
115/// truncated normal values using the parameters for each row.
116class ParameterizedTruncatedNormal {
117 public:
118 /// Optional attribute setters for ParameterizedTruncatedNormal
119 struct Attrs {
120 /// If either `seed` or `seed2` are set to be non-zero, the random number
121 /// generator is seeded by the given seed. Otherwise, it is seeded by a
122 /// random seed.
123 ///
124 /// Defaults to 0
125 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
126 Attrs ret = *this;
127 ret.seed_ = x;
128 return ret;
129 }
130
131 /// A second seed to avoid seed collision.
132 ///
133 /// Defaults to 0
134 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
135 Attrs ret = *this;
136 ret.seed2_ = x;
137 return ret;
138 }
139
140 int64 seed_ = 0;
141 int64 seed2_ = 0;
142 };
143 ParameterizedTruncatedNormal(const ::tensorflow::Scope& scope,
144 ::tensorflow::Input shape, ::tensorflow::Input
145 means, ::tensorflow::Input stdevs,
146 ::tensorflow::Input minvals, ::tensorflow::Input
147 maxvals);
148 ParameterizedTruncatedNormal(const ::tensorflow::Scope& scope,
149 ::tensorflow::Input shape, ::tensorflow::Input
150 means, ::tensorflow::Input stdevs,
151 ::tensorflow::Input minvals, ::tensorflow::Input
152 maxvals, const
153 ParameterizedTruncatedNormal::Attrs& attrs);
154 operator ::tensorflow::Output() const { return output; }
155 operator ::tensorflow::Input() const { return output; }
156 ::tensorflow::Node* node() const { return output.node(); }
157
158 static Attrs Seed(int64 x) {
159 return Attrs().Seed(x);
160 }
161 static Attrs Seed2(int64 x) {
162 return Attrs().Seed2(x);
163 }
164
165 Operation operation;
166 ::tensorflow::Output output;
167};
168
169/// Outputs random values from the Gamma distribution(s) described by alpha.
170///
171/// This op uses the algorithm by Marsaglia et al. to acquire samples via
172/// transformation-rejection from pairs of uniform and normal random variables.
173/// See http://dl.acm.org/citation.cfm?id=358414
174///
175/// Args:
176/// * scope: A Scope object
177/// * shape: 1-D integer tensor. Shape of independent samples to draw from each
178/// distribution described by the shape parameters given in alpha.
179/// * alpha: A tensor in which each scalar is a "shape" parameter describing the
180/// associated gamma distribution.
181///
182/// Optional attributes (see `Attrs`):
183/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
184/// generator is seeded by the given seed. Otherwise, it is seeded by a
185/// random seed.
186/// * seed2: A second seed to avoid seed collision.
187///
188/// Returns:
189/// * `Output`: A tensor with shape `shape + shape(alpha)`. Each slice
190/// `[:, ..., :, i0, i1, ...iN]` contains the samples drawn for
191/// `alpha[i0, i1, ...iN]`. The dtype of the output matches the dtype of alpha.
192class RandomGamma {
193 public:
194 /// Optional attribute setters for RandomGamma
195 struct Attrs {
196 /// If either `seed` or `seed2` are set to be non-zero, the random number
197 /// generator is seeded by the given seed. Otherwise, it is seeded by a
198 /// random seed.
199 ///
200 /// Defaults to 0
201 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
202 Attrs ret = *this;
203 ret.seed_ = x;
204 return ret;
205 }
206
207 /// A second seed to avoid seed collision.
208 ///
209 /// Defaults to 0
210 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
211 Attrs ret = *this;
212 ret.seed2_ = x;
213 return ret;
214 }
215
216 int64 seed_ = 0;
217 int64 seed2_ = 0;
218 };
219 RandomGamma(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
220 ::tensorflow::Input alpha);
221 RandomGamma(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
222 ::tensorflow::Input alpha, const RandomGamma::Attrs& attrs);
223 operator ::tensorflow::Output() const { return output; }
224 operator ::tensorflow::Input() const { return output; }
225 ::tensorflow::Node* node() const { return output.node(); }
226
227 static Attrs Seed(int64 x) {
228 return Attrs().Seed(x);
229 }
230 static Attrs Seed2(int64 x) {
231 return Attrs().Seed2(x);
232 }
233
234 Operation operation;
235 ::tensorflow::Output output;
236};
237
238/// Outputs random values from the Poisson distribution(s) described by rate.
239///
240/// This op uses two algorithms, depending on rate. If rate >= 10, then
241/// the algorithm by Hormann is used to acquire samples via
242/// transformation-rejection.
243/// See http://www.sciencedirect.com/science/article/pii/0167668793909974.
244///
245/// Otherwise, Knuth's algorithm is used to acquire samples via multiplying uniform
246/// random variables.
247/// See Donald E. Knuth (1969). Seminumerical Algorithms. The Art of Computer
248/// Programming, Volume 2. Addison Wesley
249///
250/// Args:
251/// * scope: A Scope object
252/// * shape: 1-D integer tensor. Shape of independent samples to draw from each
253/// distribution described by the shape parameters given in rate.
254/// * rate: A tensor in which each scalar is a "rate" parameter describing the
255/// associated poisson distribution.
256///
257/// Optional attributes (see `Attrs`):
258/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
259/// generator is seeded by the given seed. Otherwise, it is seeded by a
260/// random seed.
261/// * seed2: A second seed to avoid seed collision.
262///
263/// Returns:
264/// * `Output`: A tensor with shape `shape + shape(rate)`. Each slice
265/// `[:, ..., :, i0, i1, ...iN]` contains the samples drawn for
266/// `rate[i0, i1, ...iN]`.
267class RandomPoissonV2 {
268 public:
269 /// Optional attribute setters for RandomPoissonV2
270 struct Attrs {
271 /// If either `seed` or `seed2` are set to be non-zero, the random number
272 /// generator is seeded by the given seed. Otherwise, it is seeded by a
273 /// random seed.
274 ///
275 /// Defaults to 0
276 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
277 Attrs ret = *this;
278 ret.seed_ = x;
279 return ret;
280 }
281
282 /// A second seed to avoid seed collision.
283 ///
284 /// Defaults to 0
285 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
286 Attrs ret = *this;
287 ret.seed2_ = x;
288 return ret;
289 }
290
291 /// Defaults to DT_INT64
292 TF_MUST_USE_RESULT Attrs Dtype(DataType x) {
293 Attrs ret = *this;
294 ret.dtype_ = x;
295 return ret;
296 }
297
298 int64 seed_ = 0;
299 int64 seed2_ = 0;
300 DataType dtype_ = DT_INT64;
301 };
302 RandomPoissonV2(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
303 ::tensorflow::Input rate);
304 RandomPoissonV2(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
305 ::tensorflow::Input rate, const RandomPoissonV2::Attrs& attrs);
306 operator ::tensorflow::Output() const { return output; }
307 operator ::tensorflow::Input() const { return output; }
308 ::tensorflow::Node* node() const { return output.node(); }
309
310 static Attrs Seed(int64 x) {
311 return Attrs().Seed(x);
312 }
313 static Attrs Seed2(int64 x) {
314 return Attrs().Seed2(x);
315 }
316 static Attrs Dtype(DataType x) {
317 return Attrs().Dtype(x);
318 }
319
320 Operation operation;
321 ::tensorflow::Output output;
322};
323
324/// Randomly shuffles a tensor along its first dimension.
325///
326/// The tensor is shuffled along dimension 0, such that each `value[j]` is mapped
327/// to one and only one `output[i]`. For example, a mapping that might occur for a
328/// 3x2 tensor is:
329///
330/// ```
331/// [[1, 2], [[5, 6],
332/// [3, 4], ==> [1, 2],
333/// [5, 6]] [3, 4]]
334/// ```
335///
336/// Args:
337/// * scope: A Scope object
338/// * value: The tensor to be shuffled.
339///
340/// Optional attributes (see `Attrs`):
341/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
342/// generator is seeded by the given seed. Otherwise, it is seeded by a
343/// random seed.
344/// * seed2: A second seed to avoid seed collision.
345///
346/// Returns:
347/// * `Output`: A tensor of same shape and type as `value`, shuffled along its first
348/// dimension.
349class RandomShuffle {
350 public:
351 /// Optional attribute setters for RandomShuffle
352 struct Attrs {
353 /// If either `seed` or `seed2` are set to be non-zero, the random number
354 /// generator is seeded by the given seed. Otherwise, it is seeded by a
355 /// random seed.
356 ///
357 /// Defaults to 0
358 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
359 Attrs ret = *this;
360 ret.seed_ = x;
361 return ret;
362 }
363
364 /// A second seed to avoid seed collision.
365 ///
366 /// Defaults to 0
367 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
368 Attrs ret = *this;
369 ret.seed2_ = x;
370 return ret;
371 }
372
373 int64 seed_ = 0;
374 int64 seed2_ = 0;
375 };
376 RandomShuffle(const ::tensorflow::Scope& scope, ::tensorflow::Input value);
377 RandomShuffle(const ::tensorflow::Scope& scope, ::tensorflow::Input value,
378 const RandomShuffle::Attrs& attrs);
379 operator ::tensorflow::Output() const { return output; }
380 operator ::tensorflow::Input() const { return output; }
381 ::tensorflow::Node* node() const { return output.node(); }
382
383 static Attrs Seed(int64 x) {
384 return Attrs().Seed(x);
385 }
386 static Attrs Seed2(int64 x) {
387 return Attrs().Seed2(x);
388 }
389
390 Operation operation;
391 ::tensorflow::Output output;
392};
393
394/// Outputs random values from a normal distribution.
395///
396/// The generated values will have mean 0 and standard deviation 1.
397///
398/// Args:
399/// * scope: A Scope object
400/// * shape: The shape of the output tensor.
401/// * dtype: The type of the output.
402///
403/// Optional attributes (see `Attrs`):
404/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
405/// generator is seeded by the given seed. Otherwise, it is seeded by a
406/// random seed.
407/// * seed2: A second seed to avoid seed collision.
408///
409/// Returns:
410/// * `Output`: A tensor of the specified shape filled with random normal values.
411class RandomNormal {
412 public:
413 /// Optional attribute setters for RandomNormal
414 struct Attrs {
415 /// If either `seed` or `seed2` are set to be non-zero, the random number
416 /// generator is seeded by the given seed. Otherwise, it is seeded by a
417 /// random seed.
418 ///
419 /// Defaults to 0
420 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
421 Attrs ret = *this;
422 ret.seed_ = x;
423 return ret;
424 }
425
426 /// A second seed to avoid seed collision.
427 ///
428 /// Defaults to 0
429 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
430 Attrs ret = *this;
431 ret.seed2_ = x;
432 return ret;
433 }
434
435 int64 seed_ = 0;
436 int64 seed2_ = 0;
437 };
438 RandomNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
439 DataType dtype);
440 RandomNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
441 DataType dtype, const RandomNormal::Attrs& attrs);
442 operator ::tensorflow::Output() const { return output; }
443 operator ::tensorflow::Input() const { return output; }
444 ::tensorflow::Node* node() const { return output.node(); }
445
446 static Attrs Seed(int64 x) {
447 return Attrs().Seed(x);
448 }
449 static Attrs Seed2(int64 x) {
450 return Attrs().Seed2(x);
451 }
452
453 Operation operation;
454 ::tensorflow::Output output;
455};
456
457/// Outputs random values from a uniform distribution.
458///
459/// The generated values follow a uniform distribution in the range `[0, 1)`. The
460/// lower bound 0 is included in the range, while the upper bound 1 is excluded.
461///
462/// Args:
463/// * scope: A Scope object
464/// * shape: The shape of the output tensor.
465/// * dtype: The type of the output.
466///
467/// Optional attributes (see `Attrs`):
468/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
469/// generator is seeded by the given seed. Otherwise, it is seeded by a
470/// random seed.
471/// * seed2: A second seed to avoid seed collision.
472///
473/// Returns:
474/// * `Output`: A tensor of the specified shape filled with uniform random values.
475class RandomUniform {
476 public:
477 /// Optional attribute setters for RandomUniform
478 struct Attrs {
479 /// If either `seed` or `seed2` are set to be non-zero, the random number
480 /// generator is seeded by the given seed. Otherwise, it is seeded by a
481 /// random seed.
482 ///
483 /// Defaults to 0
484 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
485 Attrs ret = *this;
486 ret.seed_ = x;
487 return ret;
488 }
489
490 /// A second seed to avoid seed collision.
491 ///
492 /// Defaults to 0
493 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
494 Attrs ret = *this;
495 ret.seed2_ = x;
496 return ret;
497 }
498
499 int64 seed_ = 0;
500 int64 seed2_ = 0;
501 };
502 RandomUniform(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
503 DataType dtype);
504 RandomUniform(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
505 DataType dtype, const RandomUniform::Attrs& attrs);
506 operator ::tensorflow::Output() const { return output; }
507 operator ::tensorflow::Input() const { return output; }
508 ::tensorflow::Node* node() const { return output.node(); }
509
510 static Attrs Seed(int64 x) {
511 return Attrs().Seed(x);
512 }
513 static Attrs Seed2(int64 x) {
514 return Attrs().Seed2(x);
515 }
516
517 Operation operation;
518 ::tensorflow::Output output;
519};
520
521/// Outputs random integers from a uniform distribution.
522///
523/// The generated values are uniform integers in the range `[minval, maxval)`.
524/// The lower bound `minval` is included in the range, while the upper bound
525/// `maxval` is excluded.
526///
527/// The random integers are slightly biased unless `maxval - minval` is an exact
528/// power of two. The bias is small for values of `maxval - minval` significantly
529/// smaller than the range of the output (either `2^32` or `2^64`).
530///
531/// Args:
532/// * scope: A Scope object
533/// * shape: The shape of the output tensor.
534/// * minval: 0-D. Inclusive lower bound on the generated integers.
535/// * maxval: 0-D. Exclusive upper bound on the generated integers.
536///
537/// Optional attributes (see `Attrs`):
538/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
539/// generator is seeded by the given seed. Otherwise, it is seeded by a
540/// random seed.
541/// * seed2: A second seed to avoid seed collision.
542///
543/// Returns:
544/// * `Output`: A tensor of the specified shape filled with uniform random integers.
545class RandomUniformInt {
546 public:
547 /// Optional attribute setters for RandomUniformInt
548 struct Attrs {
549 /// If either `seed` or `seed2` are set to be non-zero, the random number
550 /// generator is seeded by the given seed. Otherwise, it is seeded by a
551 /// random seed.
552 ///
553 /// Defaults to 0
554 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
555 Attrs ret = *this;
556 ret.seed_ = x;
557 return ret;
558 }
559
560 /// A second seed to avoid seed collision.
561 ///
562 /// Defaults to 0
563 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
564 Attrs ret = *this;
565 ret.seed2_ = x;
566 return ret;
567 }
568
569 int64 seed_ = 0;
570 int64 seed2_ = 0;
571 };
572 RandomUniformInt(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
573 ::tensorflow::Input minval, ::tensorflow::Input maxval);
574 RandomUniformInt(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
575 ::tensorflow::Input minval, ::tensorflow::Input maxval, const
576 RandomUniformInt::Attrs& attrs);
577 operator ::tensorflow::Output() const { return output; }
578 operator ::tensorflow::Input() const { return output; }
579 ::tensorflow::Node* node() const { return output.node(); }
580
581 static Attrs Seed(int64 x) {
582 return Attrs().Seed(x);
583 }
584 static Attrs Seed2(int64 x) {
585 return Attrs().Seed2(x);
586 }
587
588 Operation operation;
589 ::tensorflow::Output output;
590};
591
592/// Outputs random values from a truncated normal distribution.
593///
594/// The generated values follow a normal distribution with mean 0 and standard
595/// deviation 1, except that values whose magnitude is more than 2 standard
596/// deviations from the mean are dropped and re-picked.
597///
598/// Args:
599/// * scope: A Scope object
600/// * shape: The shape of the output tensor.
601/// * dtype: The type of the output.
602///
603/// Optional attributes (see `Attrs`):
604/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
605/// generator is seeded by the given seed. Otherwise, it is seeded by a
606/// random seed.
607/// * seed2: A second seed to avoid seed collision.
608///
609/// Returns:
610/// * `Output`: A tensor of the specified shape filled with random truncated normal
611/// values.
612class TruncatedNormal {
613 public:
614 /// Optional attribute setters for TruncatedNormal
615 struct Attrs {
616 /// If either `seed` or `seed2` are set to be non-zero, the random number
617 /// generator is seeded by the given seed. Otherwise, it is seeded by a
618 /// random seed.
619 ///
620 /// Defaults to 0
621 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
622 Attrs ret = *this;
623 ret.seed_ = x;
624 return ret;
625 }
626
627 /// A second seed to avoid seed collision.
628 ///
629 /// Defaults to 0
630 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
631 Attrs ret = *this;
632 ret.seed2_ = x;
633 return ret;
634 }
635
636 int64 seed_ = 0;
637 int64 seed2_ = 0;
638 };
639 TruncatedNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
640 DataType dtype);
641 TruncatedNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
642 DataType dtype, const TruncatedNormal::Attrs& attrs);
643 operator ::tensorflow::Output() const { return output; }
644 operator ::tensorflow::Input() const { return output; }
645 ::tensorflow::Node* node() const { return output.node(); }
646
647 static Attrs Seed(int64 x) {
648 return Attrs().Seed(x);
649 }
650 static Attrs Seed2(int64 x) {
651 return Attrs().Seed2(x);
652 }
653
654 Operation operation;
655 ::tensorflow::Output output;
656};
657
658/// @}
659
660} // namespace ops
661} // namespace tensorflow
662
663#endif // TENSORFLOW_CC_OPS_RANDOM_OPS_H_
664