37
37
import org .tensorflow .op .math .Betainc ;
38
38
import org .tensorflow .op .math .Bincount ;
39
39
import org .tensorflow .op .math .Ceil ;
40
- import org .tensorflow .op .math .CompareAndBitpack ;
41
40
import org .tensorflow .op .math .ComplexAbs ;
42
41
import org .tensorflow .op .math .Conj ;
43
42
import org .tensorflow .op .math .Cos ;
@@ -481,11 +480,22 @@ public <T extends TType> Atan<T> atan(Operand<T> x) {
481
480
482
481
/**
483
482
* Computes arctangent of {@code y/x} element-wise, respecting signs of the arguments.
484
- * This is the angle ( \theta \in [-\pi, \pi] ) such that
485
- * [ x = r \cos(\theta) ]
483
+ * This is the angle \ ( \theta \in [-\pi, \pi] \ ) such that
484
+ * \ [ x = r \cos(\theta) \ ]
486
485
* and
487
- * [ y = r \sin(\theta) ]
488
- * where (r = \sqrt(x^2 + y^2) ).
486
+ * \[ y = r \sin(\theta) \]
487
+ * where \(r = \sqrt{x^2 + y^2} \).
488
+ * <p>For example:
489
+ * <blockquote>
490
+ * <blockquote>
491
+ * <blockquote>
492
+ * <p>x = [1., 1.]
493
+ * y = [1., -1.]
494
+ * print((tf.math.atan2(y,x) * (180 / np.pi)).numpy())
495
+ * [ 45. -45.]
496
+ * </blockquote>
497
+ * </blockquote>
498
+ * </blockquote>
489
499
*
490
500
* @param <T> data type for {@code z} output
491
501
* @param y the y value
@@ -573,44 +583,22 @@ public <T extends TNumber> Ceil<T> ceil(Operand<T> x) {
573
583
return Ceil .create (scope , x );
574
584
}
575
585
576
- /**
577
- * Compare values of {@code input} to {@code threshold} and pack resulting bits into a {@code uint8}.
578
- * Each comparison returns a boolean {@code true} (if {@code input_value > threshold})
579
- * or and {@code false} otherwise.
580
- * <p>This operation is useful for Locality-Sensitive-Hashing (LSH) and other
581
- * algorithms that use hashing approximations of cosine and {@code L2} distances;
582
- * codes can be generated from an input via:
583
- * <pre>
584
- * codebook_size = 50
585
- * codebook_bits = codebook_size * 32
586
- * codebook = tf.get_variable('codebook', [x.shape[-1].value, codebook_bits],
587
- * dtype=x.dtype,
588
- * initializer=tf.orthogonal_initializer())
589
- * codes = compare_and_threshold(tf.matmul(x, codebook), threshold=0.)
590
- * codes = tf.bitcast(codes, tf.int32) # go from uint8 to int32
591
- * # now codes has shape x.shape[:-1] + [codebook_size]
592
- * </pre>
593
- * <p><strong>NOTE</strong>: Currently, the innermost dimension of the tensor must be divisible
594
- * by 8.
595
- * <p>Given an {@code input} shaped {@code [s0, s1, ..., s_n]}, the output is
596
- * a {@code uint8} tensor shaped {@code [s0, s1, ..., s_n / 8]}.
597
- *
598
- * @param input Values to compare against {@code threshold} and bitpack.
599
- * @param threshold Threshold to compare against.
600
- * @param <T> data type for {@code CompareAndBitpack} output and operands
601
- * @return a new instance of CompareAndBitpack
602
- */
603
- public <T extends TType > CompareAndBitpack compareAndBitpack (Operand <T > input ,
604
- Operand <T > threshold ) {
605
- return CompareAndBitpack .create (scope , input , threshold );
606
- }
607
-
608
586
/**
609
587
* Computes the complex absolute value of a tensor.
610
588
* Given a tensor {@code x} of complex numbers, this operation returns a tensor of type
611
589
* {@code float} or {@code double} that is the absolute value of each element in {@code x}. All
612
590
* elements in {@code x} must be complex numbers of the form \(a + bj\). The absolute
613
591
* value is computed as \( \sqrt{a^2 + b^2}\).
592
+ * <p>For example:
593
+ * <blockquote>
594
+ * <blockquote>
595
+ * <blockquote>
596
+ * <p>x = tf.complex(3.0, 4.0)
597
+ * print((tf.raw_ops.ComplexAbs(x=x, Tout=tf.dtypes.float32, name=None)).numpy())
598
+ * 5.0
599
+ * </blockquote>
600
+ * </blockquote>
601
+ * </blockquote>
614
602
*
615
603
* @param <U> data type for {@code y} output
616
604
* @param x the x value
@@ -626,6 +614,16 @@ public ComplexAbs<TFloat32> complexAbs(Operand<? extends TType> x) {
626
614
* {@code float} or {@code double} that is the absolute value of each element in {@code x}. All
627
615
* elements in {@code x} must be complex numbers of the form \(a + bj\). The absolute
628
616
* value is computed as \( \sqrt{a^2 + b^2}\).
617
+ * <p>For example:
618
+ * <blockquote>
619
+ * <blockquote>
620
+ * <blockquote>
621
+ * <p>x = tf.complex(3.0, 4.0)
622
+ * print((tf.raw_ops.ComplexAbs(x=x, Tout=tf.dtypes.float32, name=None)).numpy())
623
+ * 5.0
624
+ * </blockquote>
625
+ * </blockquote>
626
+ * </blockquote>
629
627
*
630
628
* @param <U> data type for {@code y} output
631
629
* @param x the x value
@@ -867,7 +865,7 @@ public <T extends TType> Equal equal(Operand<T> x, Operand<T> y, Equal.Options..
867
865
}
868
866
869
867
/**
870
- * Computes the Gauss error function of {@code x} element-wise.
868
+ * Computes the <a href="https://en.wikipedia.org/wiki/Error_function"> Gauss error function</a> of {@code x} element-wise. In statistics, for non-negative values of $x$, the error function has the following interpretation: for a random variable $Y$ that is normally distributed with mean 0 and variance $1/\sqrt{2}$, $erf(x)$ is the probability that $Y$ falls in the range $[−x, x]$ .
871
869
*
872
870
* @param <T> data type for {@code y} output
873
871
* @param x the x value
@@ -1085,8 +1083,8 @@ public <T extends TNumber> Igamma<T> igamma(Operand<T> a, Operand<T> x) {
1085
1083
* The upper regularized incomplete Gamma function is defined as:
1086
1084
* <p>\(Q(a, x) = Gamma(a, x) / Gamma(a) = 1 - P(a, x)\)
1087
1085
* <p>where
1088
- * <p>\(Gamma(a, x) = int_{x}^{\infty} t^{a-1} exp(-t) dt\)
1089
- * <p>is the upper incomplete Gama function.
1086
+ * <p>\(Gamma(a, x) = \ int_{x}^{\infty} t^{a-1} exp(-t) dt\)
1087
+ * <p>is the upper incomplete Gamma function.
1090
1088
* <p>Note, above {@code P(a, x)} ({@code Igamma}) is the lower regularized complete
1091
1089
* Gamma function.
1092
1090
*
@@ -2234,9 +2232,9 @@ public <T extends TType> UnsortedSegmentProd<T> unsortedSegmentProd(Operand<T> d
2234
2232
* </div>
2235
2233
* <pre>
2236
2234
* c = tf.constant([[1,2,3,4], [5,6,7,8], [4,3,2,1]])
2237
- * tf.unsorted_segment_sum(c, tf.constant([0, 1, 0]), num_segments=2)
2238
- * # ==> [[ 5, 5, 5, 5],
2239
- * # [5, 6, 7, 8]]
2235
+ * tf.math. unsorted_segment_sum(c, tf.constant([0, 1, 0]), num_segments=2)
2236
+ * # ==> [[ 5, 5, 5, 5],
2237
+ * # [5, 6, 7, 8]]
2240
2238
* </pre>
2241
2239
*
2242
2240
* @param <T> data type for {@code output} output
0 commit comments