forked from tensorflow/swift-bindings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRawOpsGenerated.swift
19749 lines (19091 loc) · 658 KB
/
RawOpsGenerated.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// !!!THIS CODE IS AUTOMATICALLY GENERATED, DO NOT EDIT BY HAND!!!
//
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
public enum Raw {
static let generatedTensorFlowVersion = "1.9.0-rc1"
static let generatedTensorFlowGitVersion = "v1.9.0-rc0-35-g17d6639b55"
@_frozen
public enum A {
case apples
case oranges
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .apples: return "apples"
case .oranges: return "oranges"
}
}
}
}
@_frozen
public enum DataFormat {
case nchw
case nhwc
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .nchw: return "NCHW"
case .nhwc: return "NHWC"
}
}
}
}
@_frozen
public enum DataFormat1 {
case ncdhw
case ndhwc
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .ncdhw: return "NCDHW"
case .ndhwc: return "NDHWC"
}
}
}
}
@_frozen
public enum DataFormat3 {
case nchw
case nchwVectC
case nhwc
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .nchw: return "NCHW"
case .nchwVectC: return "NCHW_VECT_C"
case .nhwc: return "NHWC"
}
}
}
}
@_frozen
public enum DensityUnit {
case cm
case in_
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .cm: return "cm"
case .in_: return "in"
}
}
}
}
@_frozen
public enum Direction {
case bidirectional
case unidirectional
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .bidirectional: return "bidirectional"
case .unidirectional: return "unidirectional"
}
}
}
}
@_frozen
public enum FinalOp {
case div
case id
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .div: return "Div"
case .id: return "Id"
}
}
}
}
@_frozen
public enum Format {
case empty
case grayscale
case rgb
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .empty: return ""
case .grayscale: return "grayscale"
case .rgb: return "rgb"
}
}
}
}
@_frozen
public enum InputMode {
case autoSelect
case linearInput
case skipInput
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .autoSelect: return "auto_select"
case .linearInput: return "linear_input"
case .skipInput: return "skip_input"
}
}
}
}
@_frozen
public enum LossType {
case hingeLoss
case logisticLoss
case smoothHingeLoss
case squaredLoss
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .hingeLoss: return "hinge_loss"
case .logisticLoss: return "logistic_loss"
case .smoothHingeLoss: return "smooth_hinge_loss"
case .squaredLoss: return "squared_loss"
}
}
}
}
@_frozen
public enum MergeOp {
case add
case max
case min
case mul
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .add: return "Add"
case .max: return "Max"
case .min: return "Min"
case .mul: return "Mul"
}
}
}
}
@_frozen
public enum Method {
case bilinear
case nearest
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .bilinear: return "bilinear"
case .nearest: return "nearest"
}
}
}
}
@_frozen
public enum Method2 {
case bilinear
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .bilinear: return "bilinear"
}
}
}
}
@_frozen
public enum Mode {
case minCombined
case minFirst
case scaled
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .minCombined: return "MIN_COMBINED"
case .minFirst: return "MIN_FIRST"
case .scaled: return "SCALED"
}
}
}
}
@_frozen
public enum Mode4 {
case reflect
case symmetric
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .reflect: return "REFLECT"
case .symmetric: return "SYMMETRIC"
}
}
}
}
@_frozen
public enum Padding {
case same
case valid
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .same: return "SAME"
case .valid: return "VALID"
}
}
}
}
@_frozen
public enum RnnMode {
case gru
case lstm
case rnnRelu
case rnnTanh
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .gru: return "gru"
case .lstm: return "lstm"
case .rnnRelu: return "rnn_relu"
case .rnnTanh: return "rnn_tanh"
}
}
}
}
@_frozen
public enum RoundMode {
case halfAwayFromZero
case halfToEven
@inlinable
var cName: String {
@inline(__always)
get {
switch self {
case .halfAwayFromZero: return "HALF_AWAY_FROM_ZERO"
case .halfToEven: return "HALF_TO_EVEN"
}
}
}
}
@inlinable @inline(__always)
public static func a(
) -> Tensor<Float> {
return #tfop("A")
}
/// Raise a exception to abort the process when called.
///
/// If exit_without_error is true, the process will exit normally,
/// otherwise it will exit with a SIGABORT signal.
///
/// Returns nothing but an exception.
///
/// - Attr error_msg: A string which is the message associated with the exception.
@inlinable @inline(__always)
public static func abort(
errorMsg: String,
exitWithoutError: Bool = false
) {
return #tfop("Abort",
error_msg: errorMsg,
exit_without_error: exitWithoutError)
}
/// Computes the absolute value of a tensor.
///
/// Given a tensor `x`, this operation returns a tensor containing the absolute
/// value of each element in `x`. For example, if x is an input element and y is
/// an output element, this operation computes \\(y = |x|\\).
@inlinable @inline(__always)
public static func abs<T: Numeric>(
_ x: Tensor<T>
) -> Tensor<T> {
return #tfop("Abs",
x,
T: T.self)
}
/// Computes acos of x element-wise.
@inlinable @inline(__always)
public static func acos<T: Numeric>(
_ x: Tensor<T>
) -> Tensor<T> {
return #tfop("Acos",
x,
T: T.self)
}
/// Computes inverse hyperbolic cosine of x element-wise.
@inlinable @inline(__always)
public static func acosh<T: BinaryFloatingPoint>(
_ x: Tensor<T>
) -> Tensor<T> {
return #tfop("Acosh",
x,
T: T.self)
}
/// Returns x + y element-wise.
///
/// *NOTE*: `Add` supports broadcasting. `AddN` does not. More about broadcasting
/// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html)
@inlinable @inline(__always)
public static func add<T: Numeric>(
_ x: Tensor<T>,
_ y: Tensor<T>
) -> Tensor<T> {
return #tfop("Add",
x,
y,
T: T.self)
}
/// Add an `N`-minibatch `SparseTensor` to a `SparseTensorsMap`, return `N` handles.
///
/// A `SparseTensor` of rank `R` is represented by three tensors: `sparse_indices`,
/// `sparse_values`, and `sparse_shape`, where
///
/// ```sparse_indices.shape[1] == sparse_shape.shape[0] == R```
///
/// An `N`-minibatch of `SparseTensor` objects is represented as a `SparseTensor`
/// having a first `sparse_indices` column taking values between `[0, N)`, where
/// the minibatch size `N == sparse_shape[0]`.
///
/// The input `SparseTensor` must have rank `R` greater than 1, and the first
/// dimension is treated as the minibatch dimension. Elements of the `SparseTensor`
/// must be sorted in increasing order of this first dimension. The stored
/// `SparseTensor` objects pointed to by each row of the output `sparse_handles`
/// will have rank `R-1`.
///
/// The `SparseTensor` values can then be read out as part of a minibatch by passing
/// the given keys as vector elements to `TakeManySparseFromTensorsMap`. To ensure
/// the correct `SparseTensorsMap` is accessed, ensure that the same
/// `container` and `shared_name` are passed to that Op. If no `shared_name`
/// is provided here, instead use the *name* of the Operation created by calling
/// `AddManySparseToTensorsMap` as the `shared_name` passed to
/// `TakeManySparseFromTensorsMap`. Ensure the Operations are colocated.
///
/// - Parameters:
/// - sparse_indices: 2-D. The `indices` of the minibatch `SparseTensor`.
/// `sparse_indices[:, 0]` must be ordered values in `[0, N)`.
/// - sparse_values: 1-D. The `values` of the minibatch `SparseTensor`.
/// - sparse_shape: 1-D. The `shape` of the minibatch `SparseTensor`.
/// The minibatch size `N == sparse_shape[0]`.
///
/// - Attrs:
/// - container: The container name for the `SparseTensorsMap` created by this op.
/// - shared_name: The shared name for the `SparseTensorsMap` created by this op.
/// If blank, the new Operation's unique name is used.
///
/// - Output sparse_handles: 1-D. The handles of the `SparseTensor` now stored in the
/// `SparseTensorsMap`. Shape: `[N]`.
@inlinable @inline(__always)
public static func addManySparseToTensorsMap<T: AccelerableByTensorFlow>(
sparseIndices: Tensor<Int64>,
sparseValues: Tensor<T>,
sparseShape: Tensor<Int64>,
container: String,
sharedName: String
) -> Tensor<Int64> {
return #tfop("AddManySparseToTensorsMap",
sparseIndices,
sparseValues,
sparseShape,
T: T.self,
container: container,
shared_name: sharedName)
}
/// Add all input tensors element wise.
///
/// - Parameter inputs: Must all be the same size and shape.
@inlinable @inline(__always)
public static func addN<T: Numeric>(
inputs: [Tensor<T>]
) -> Tensor<T> {
return #tfop("AddN",
inputs,
T: T.self)
}
/// Add a `SparseTensor` to a `SparseTensorsMap` return its handle.
///
/// A `SparseTensor` is represented by three tensors: `sparse_indices`,
/// `sparse_values`, and `sparse_shape`.
///
/// This operator takes the given `SparseTensor` and adds it to a container
/// object (a `SparseTensorsMap`). A unique key within this container is generated
/// in the form of an `int64`, and this is the value that is returned.
///
/// The `SparseTensor` can then be read out as part of a minibatch by passing
/// the key as a vector element to `TakeManySparseFromTensorsMap`. To ensure
/// the correct `SparseTensorsMap` is accessed, ensure that the same
/// `container` and `shared_name` are passed to that Op. If no `shared_name`
/// is provided here, instead use the *name* of the Operation created by calling
/// `AddSparseToTensorsMap` as the `shared_name` passed to
/// `TakeManySparseFromTensorsMap`. Ensure the Operations are colocated.
///
/// - Parameters:
/// - sparse_indices: 2-D. The `indices` of the `SparseTensor`.
/// - sparse_values: 1-D. The `values` of the `SparseTensor`.
/// - sparse_shape: 1-D. The `shape` of the `SparseTensor`.
///
/// - Attrs:
/// - container: The container name for the `SparseTensorsMap` created by this op.
/// - shared_name: The shared name for the `SparseTensorsMap` created by this op.
/// If blank, the new Operation's unique name is used.
///
/// - Output sparse_handle: 0-D. The handle of the `SparseTensor` now stored in the
/// `SparseTensorsMap`.
@inlinable @inline(__always)
public static func addSparseToTensorsMap<T: AccelerableByTensorFlow>(
sparseIndices: Tensor<Int64>,
sparseValues: Tensor<T>,
sparseShape: Tensor<Int64>,
container: String,
sharedName: String
) -> Tensor<Int64> {
return #tfop("AddSparseToTensorsMap",
sparseIndices,
sparseValues,
sparseShape,
T: T.self,
container: container,
shared_name: sharedName)
}
/// Returns x + y element-wise.
///
/// *NOTE*: `Add` supports broadcasting. `AddN` does not. More about broadcasting
/// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html)
@inlinable @inline(__always)
public static func addV2<T: Numeric>(
_ x: Tensor<T>,
_ y: Tensor<T>
) -> Tensor<T> {
return #tfop("AddV2",
x,
y,
T: T.self)
}
/// Deprecated. Disallowed in GraphDef version >= 2.
@inlinable @inline(__always)
public static func adjustContrast<T: Numeric>(
images: Tensor<T>,
contrastFactor: Tensor<Float>,
minValue: Tensor<Float>,
maxValue: Tensor<Float>
) -> Tensor<Float> {
return #tfop("AdjustContrast",
images,
contrastFactor,
minValue,
maxValue,
T: T.self)
}
/// Adjust the contrast of one or more images.
///
/// `images` is a tensor of at least 3 dimensions. The last 3 dimensions are
/// interpreted as `[height, width, channels]`. The other dimensions only
/// represent a collection of images, such as `[batch, height, width, channels].`
///
/// Contrast is adjusted independently for each channel of each image.
///
/// For each channel, the Op first computes the mean of the image pixels in the
/// channel and then adjusts each component of each pixel to
/// `(x - mean) * contrast_factor + mean`.
///
/// - Parameters:
/// - images: Images to adjust. At least 3-D.
/// - contrast_factor: A float multiplier for adjusting contrast.
///
/// - Output output: The contrast-adjusted image or images.
@inlinable @inline(__always)
public static func adjustContrastv2(
images: Tensor<Float>,
contrastFactor: Tensor<Float>
) -> Tensor<Float> {
return #tfop("AdjustContrastv2",
images,
contrastFactor)
}
/// Adjust the hue of one or more images.
///
/// `images` is a tensor of at least 3 dimensions. The last dimension is
/// interpretted as channels, and must be three.
///
/// The input image is considered in the RGB colorspace. Conceptually, the RGB
/// colors are first mapped into HSV. A delta is then applied all the hue values,
/// and then remapped back to RGB colorspace.
///
/// - Parameters:
/// - images: Images to adjust. At least 3-D.
/// - delta: A float delta to add to the hue.
///
/// - Output output: The hue-adjusted image or images.
@inlinable @inline(__always)
public static func adjustHue(
images: Tensor<Float>,
delta: Tensor<Float>
) -> Tensor<Float> {
return #tfop("AdjustHue",
images,
delta)
}
/// Adjust the saturation of one or more images.
///
/// `images` is a tensor of at least 3 dimensions. The last dimension is
/// interpretted as channels, and must be three.
///
/// The input image is considered in the RGB colorspace. Conceptually, the RGB
/// colors are first mapped into HSV. A scale is then applied all the saturation
/// values, and then remapped back to RGB colorspace.
///
/// - Parameters:
/// - images: Images to adjust. At least 3-D.
/// - scale: A float scale to add to the saturation.
///
/// - Output output: The hue-adjusted image or images.
@inlinable @inline(__always)
public static func adjustSaturation(
images: Tensor<Float>,
scale: Tensor<Float>
) -> Tensor<Float> {
return #tfop("AdjustSaturation",
images,
scale)
}
/// Computes the "logical and" of elements across dimensions of a tensor.
///
/// Reduces `input` along the dimensions given in `axis`. Unless
/// `keep_dims` is true, the rank of the tensor is reduced by 1 for each entry in
/// `axis`. If `keep_dims` is true, the reduced dimensions are
/// retained with length 1.
///
/// - Parameters:
/// - input: The tensor to reduce.
/// - reduction_indices: The dimensions to reduce. Must be in the range
/// `[-rank(input), rank(input))`.
///
/// - Attr keep_dims: If true, retain reduced dimensions with length 1.
///
/// - Output output: The reduced tensor.
@inlinable @inline(__always)
public static func all<Tidx: BinaryInteger>(
_ input: Tensor<Bool>,
reductionIndices: Tensor<Tidx>,
keepDims: Bool = false
) -> Tensor<Bool> {
return #tfop("All",
input,
reductionIndices,
Tidx: Tidx.self,
keep_dims: keepDims)
}
/// Generates labels for candidate sampling with a learned unigram distribution.
///
/// See explanations of candidate sampling and the data formats at
/// go/candidate-sampling.
///
/// For each batch, this op picks a single set of sampled candidate labels.
///
/// The advantages of sampling candidates per-batch are simplicity and the
/// possibility of efficient dense matrix multiplication. The disadvantage is that
/// the sampled candidates must be chosen independently of the context and of the
/// true labels.
///
/// - Parameter true_classes: A batch_size * num_true matrix, in which each row contains the
/// IDs of the num_true target_classes in the corresponding original label.
///
/// - Attrs:
/// - num_true: Number of true labels per context.
/// - num_sampled: Number of candidates to produce.
/// - unique: If unique is true, we sample with rejection, so that all sampled
/// candidates in a batch are unique. This requires some approximation to
/// estimate the post-rejection sampling probabilities.
/// - seed: If either seed or seed2 are set to be non-zero, the random number
/// generator is seeded by the given seed. Otherwise, it is seeded by a
/// random seed.
/// - seed2: An second seed to avoid seed collision.
///
/// - Outputs:
/// - sampled_candidates: A vector of length num_sampled, in which each element is
/// the ID of a sampled candidate.
/// - true_expected_count: A batch_size * num_true matrix, representing
/// the number of times each candidate is expected to occur in a batch
/// of sampled candidates. If unique=true, then this is a probability.
/// - sampled_expected_count: A vector of length num_sampled, for each sampled
/// candidate representing the number of times the candidate is expected
/// to occur in a batch of sampled candidates. If unique=true, then this is a
/// probability.
@inlinable @inline(__always)
public static func allCandidateSampler(
trueClasses: Tensor<Int64>,
numTrue: Int64,
numSampled: Int64,
unique: Bool,
seed: Int64 = 0,
seed2: Int64 = 0
) -> (sampledCandidates: Tensor<Int64>, trueExpectedCount: Tensor<Float>, sampledExpectedCount: Tensor<Float>) {
return #tfop("AllCandidateSampler",
trueClasses,
num_true: numTrue,
num_sampled: numSampled,
unique: unique,
seed: seed,
seed2: seed2)
}
/// Returns the argument of a complex number.
///
/// Given a tensor `input` of complex numbers, this operation returns a tensor of
/// type `float` that is the argument of each element in `input`. All elements in
/// `input` must be complex numbers of the form \\(a + bj\\), where *a*
/// is the real part and *b* is the imaginary part.
///
/// The argument returned by this operation is of the form \\(atan2(b, a)\\).
///
/// For example:
///
/// ```
/// # tensor 'input' is [-2.25 + 4.75j, 3.25 + 5.75j]
/// tf.angle(input) ==> [2.0132, 1.056]
/// ```
///
/// @compatibility(numpy)
/// Equivalent to np.angle.
/// @end_compatibility
@inlinable @inline(__always)
public static func angle<T: AccelerableByTensorFlow, Tout: BinaryFloatingPoint>(
_ input: Tensor<T>
) -> Tensor<Tout> {
return #tfop("Angle",
input,
T: T.self,
Tout: Tout.self)
}
/// Computes the "logical or" of elements across dimensions of a tensor.
///
/// Reduces `input` along the dimensions given in `axis`. Unless
/// `keep_dims` is true, the rank of the tensor is reduced by 1 for each entry in
/// `axis`. If `keep_dims` is true, the reduced dimensions are
/// retained with length 1.
///
/// - Parameters:
/// - input: The tensor to reduce.
/// - reduction_indices: The dimensions to reduce. Must be in the range
/// `[-rank(input), rank(input))`.
///
/// - Attr keep_dims: If true, retain reduced dimensions with length 1.
///
/// - Output output: The reduced tensor.
@inlinable @inline(__always)
public static func any<Tidx: BinaryInteger>(
_ input: Tensor<Bool>,
reductionIndices: Tensor<Tidx>,
keepDims: Bool = false
) -> Tensor<Bool> {
return #tfop("Any",
input,
reductionIndices,
Tidx: Tidx.self,
keep_dims: keepDims)
}
/// Update '*var' according to the AdaMax algorithm.
///
/// m_t <- beta1 * m_{t-1} + (1 - beta1) * g
/// v_t <- max(beta2 * v_{t-1}, abs(g))
/// variable <- variable - learning_rate / (1 - beta1^t) * m_t / (v_t + epsilon)
///
/// - Parameters:
/// - var: Should be from a Variable().
/// - m: Should be from a Variable().
/// - v: Should be from a Variable().
/// - beta1_power: Must be a scalar.
/// - lr: Scaling factor. Must be a scalar.
/// - beta1: Momentum factor. Must be a scalar.
/// - beta2: Momentum factor. Must be a scalar.
/// - epsilon: Ridge term. Must be a scalar.
/// - grad: The gradient.
///
/// - Attr use_locking: If `True`, updating of the var, m, and v tensors will be protected
/// by a lock; otherwise the behavior is undefined, but may exhibit less
/// contention.
///
/// - Output out: Same as "var".
@inlinable @inline(__always)
public static func applyAdaMax<T: Numeric>(
var_: Tensor<T>,
m: Tensor<T>,
v: Tensor<T>,
beta1Power: Tensor<T>,
lr: Tensor<T>,
beta1: Tensor<T>,
beta2: Tensor<T>,
epsilon: Tensor<T>,
grad: Tensor<T>,
useLocking: Bool = false
) -> Tensor<T> {
return #tfop("ApplyAdaMax",
var_,
m,
v,
beta1Power,
lr,
beta1,
beta2,
epsilon,
grad,
T: T.self,
use_locking: useLocking)
}
/// Update '*var' according to the adadelta scheme.
///
/// accum = rho() * accum + (1 - rho()) * grad.square();
/// update = (update_accum + epsilon).sqrt() * (accum + epsilon()).rsqrt() * grad;
/// update_accum = rho() * update_accum + (1 - rho()) * update.square();
/// var -= update;
///
/// - Parameters:
/// - var: Should be from a Variable().
/// - accum: Should be from a Variable().
/// - accum_update: Should be from a Variable().
/// - lr: Scaling factor. Must be a scalar.
/// - rho: Decay factor. Must be a scalar.
/// - epsilon: Constant factor. Must be a scalar.
/// - grad: The gradient.
///
/// - Attr use_locking: If True, updating of the var, accum and update_accum tensors will be protected by
/// a lock; otherwise the behavior is undefined, but may exhibit less contention.
///
/// - Output out: Same as "var".
@inlinable @inline(__always)
public static func applyAdadelta<T: Numeric>(
var_: Tensor<T>,
accum: Tensor<T>,
accumUpdate: Tensor<T>,
lr: Tensor<T>,
rho: Tensor<T>,
epsilon: Tensor<T>,
grad: Tensor<T>,
useLocking: Bool = false
) -> Tensor<T> {
return #tfop("ApplyAdadelta",
var_,
accum,
accumUpdate,
lr,
rho,
epsilon,
grad,
T: T.self,
use_locking: useLocking)
}
/// Update '*var' according to the adagrad scheme.
///
/// accum += grad * grad
/// var -= lr * grad * (1 / sqrt(accum))
///
/// - Parameters:
/// - var: Should be from a Variable().
/// - accum: Should be from a Variable().
/// - lr: Scaling factor. Must be a scalar.
/// - grad: The gradient.
///
/// - Attr use_locking: If `True`, updating of the var and accum tensors will be protected
/// by a lock; otherwise the behavior is undefined, but may exhibit less
/// contention.
///
/// - Output out: Same as "var".
@inlinable @inline(__always)
public static func applyAdagrad<T: Numeric>(
var_: Tensor<T>,
accum: Tensor<T>,
lr: Tensor<T>,
grad: Tensor<T>,
useLocking: Bool = false,
updateSlots: Bool = true
) -> Tensor<T> {
return #tfop("ApplyAdagrad",
var_,
accum,
lr,
grad,
T: T.self,
use_locking: useLocking,
update_slots: updateSlots)
}
/// Update '*var' according to the proximal adagrad scheme.
///
/// - Parameters:
/// - var: Should be from a Variable().
/// - gradient_accumulator: Should be from a Variable().
/// - gradient_squared_accumulator: Should be from a Variable().
/// - grad: The gradient.
/// - lr: Scaling factor. Must be a scalar.
/// - l1: L1 regularization. Must be a scalar.
/// - l2: L2 regularization. Must be a scalar.
/// - global_step: Training step number. Must be a scalar.
///
/// - Attr use_locking: If True, updating of the var and accum tensors will be protected by
/// a lock; otherwise the behavior is undefined, but may exhibit less contention.
///
/// - Output out: Same as "var".
@inlinable @inline(__always)
public static func applyAdagradDA<T: Numeric>(
var_: Tensor<T>,
gradientAccumulator: Tensor<T>,
gradientSquaredAccumulator: Tensor<T>,
grad: Tensor<T>,
lr: Tensor<T>,
l1: Tensor<T>,
l2: Tensor<T>,
globalStep: Tensor<Int64>,
useLocking: Bool = false
) -> Tensor<T> {
return #tfop("ApplyAdagradDA",
var_,
gradientAccumulator,
gradientSquaredAccumulator,
grad,
lr,
l1,
l2,
globalStep,
T: T.self,
use_locking: useLocking)
}
/// Update '*var' according to the Adam algorithm.
///
/// $$lr_t := \text{learning_rate} * \sqrt{(1 - beta_2^t) / (1 - beta_1^t)}$$
/// $$m_t := beta_1 * m_{t-1} + (1 - beta_1) * g$$
/// $$v_t := beta_2 * v_{t-1} + (1 - beta_2) * g * g$$
/// $$variable := variable - lr_t * m_t / (\sqrt{v_t} + \epsilon)$$
///
/// - Parameters:
/// - var: Should be from a Variable().
/// - m: Should be from a Variable().
/// - v: Should be from a Variable().
/// - beta1_power: Must be a scalar.
/// - beta2_power: Must be a scalar.
/// - lr: Scaling factor. Must be a scalar.
/// - beta1: Momentum factor. Must be a scalar.
/// - beta2: Momentum factor. Must be a scalar.
/// - epsilon: Ridge term. Must be a scalar.
/// - grad: The gradient.
///
/// - Attrs:
/// - use_locking: If `True`, updating of the var, m, and v tensors will be protected
/// by a lock; otherwise the behavior is undefined, but may exhibit less
/// contention.
/// - use_nesterov: If `True`, uses the nesterov update.
///
/// - Output out: Same as "var".
@inlinable @inline(__always)
public static func applyAdam<T: Numeric>(
var_: Tensor<T>,
m: Tensor<T>,
v: Tensor<T>,
beta1Power: Tensor<T>,
beta2Power: Tensor<T>,
lr: Tensor<T>,
beta1: Tensor<T>,
beta2: Tensor<T>,
epsilon: Tensor<T>,
grad: Tensor<T>,
useLocking: Bool = false,
useNesterov: Bool = false
) -> Tensor<T> {
return #tfop("ApplyAdam",
var_,
m,
v,
beta1Power,
beta2Power,
lr,
beta1,
beta2,
epsilon,
grad,
T: T.self,
use_locking: useLocking,