forked from sony/nnabla
/
functions.yaml
executable file
·5119 lines (4536 loc) · 141 KB
/
functions.yaml
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
Neural Network Layer:
Affine:
snake_name: affine
doc: |2
Affine layer, also called as the fully connected layer. It calculates:
.. math::
{\mathbf y} = {\mathbf A} {\mathbf x} + {\mathbf b}.
where :math:`{\mathbf x}` is the input and :math:`{\mathbf y}` is the output.
inputs:
x:
doc: Input N-D array with shape (:math:`M_0 \times ... \times M_{B-1} \times
D_B \times ... \times D_N`). Dimensions before and after base_axis are flattened
as if it is a matrix.
weight:
doc: Weight matrix with shape (:math:`(D_B \times ... \times D_N) \times L`)
parameter: true
bias:
doc: Bias vector (:math:`L`)
optional: true
parameter: true
arguments:
base_axis:
doc: Base axis of Affine operation. Dimensions up to base_axis is treated
as sample dimension.
type: int64
default: '1'
outputs:
y:
doc: :math:`(B + 1)`-D array. (:math:`M_0 \times ... \times M_{B-1} \times
L`)
function_ids:
i: 0
c_runtime: support
RNN:
snake_name: rnn
doc: |2
RNN function implements Elman RNN with nonlineraity to input sequence.
RNN function is defined as following:
.. math::
{\mathbf h_t} = {\mathbf \tanh}( {\mathbf w_{ih}} *{\mathbf x_t} + {\mathbf b_{ih}} + {\mathbf w_{hh}}* {\mathbf h_{(t-1)}} + {\mathbf b_{hh}}).
We use the following notations to describe the inputs and outputs below.
:math:`T`: sequcne length, :math:`B`: batch size, :math:`I`: input size, :math:`L`: number of layers, :math:`D`: number of directions, can be either 1 or 2, :math:`H`: hidden size.
References:
* `Jeffrey Elman, Finding Structure in Time. <https://crl.ucsd.edu/~elman/Papers/fsit.pdf>`_
inputs:
x:
doc: Input N-D array with shape :math:`(T, B, I)`.
h:
doc: Input N-D array with shape :math:`(L, D, B, H)`.
weight_l0:
doc: Input N-D array with shape :math:`(D, H, I + H)`.
parameter: true
weight:
doc: Input N-D array with shape :math:`(L-1, D, H, D * H + H)`.
optional: true
parameter: true
bias:
doc: Input N-D array with shape :math:`(L, D, H)`.
optional: true
parameter: true
arguments:
num_layers:
doc: Number of layers in the network. If set to 1, only the weights for the
first layer will be invoked. Default is 1.
type: int64
default: '1'
nonlinearity:
doc: Type of nonlinearity applied to input sequcne. Must be either tanh or
relu. Default is tanh.
type: string
available_values:
- tanh
- relu
default: tanh
dropout:
doc: Dropout ratio applied to parameters. Default is 0.0.
type: float
default: 0.0
bidirectional:
doc: If True, bidirectional computation will be performed in each layer. Default
is False.
type: bool
default: 'False'
training:
doc: Backpropagation will be performed only when it is true. Default is True.
type: bool
default: 'True'
outputs:
y:
doc: Output :math:`y` with shape :math:`(T, B, D * H)`
h_n:
doc: Output :math:`h_n` with shape :math:`(L, D, B, H)`
function_ids:
iifBB: 244
c_runtime: not support
LSTM:
snake_name: lstm
doc: |2
N-Step LSTM layer.
.. math::
{\mathbf f_t} = {\mathbf \sigma}( {\mathbf W_f} *{\mathbf x_t} + {\mathbf U_f}* {\mathbf h_{(t-1)}} + {\mathbf b_f})\\
{\mathbf i_t} = {\mathbf \sigma}( {\mathbf W_i} *{\mathbf x_t} + {\mathbf U_i}* {\mathbf h_{(t-1)}} + {\mathbf b_i})\\
{\mathbf o_t} = {\mathbf \sigma}( {\mathbf W_o} *{\mathbf x_t} + {\mathbf U_o}* {\mathbf h_{(t-1)}} + {\mathbf b_o})\\
{\mathbf c_t} = {\mathbf f_t}\odot {mathbf c_{(t-1)}} + {\mathbf i_t}\odot {\mathbf \tanh}({\mathbf W_c}*{\mathbf x_t} + {\mathbf U_c} *{\mathbf h_{(t-1)}} + {\mathbf b_c})\\
{\mathbf h_t} = {\mathbf o_t} \odot {\mathbf \tanh}({\mathbf c_t}).
We use the following notations to describe the inputs and outputs below.
:math:`T`: sequcne length, :math:`B`: batch size, :math:`I`: input size, :math:`L`: number of layers, :math:`D`: number of directions, can be either 1 or 2, :math:`H`: hidden size.
References:
* `S. Hochreiter and J. Schmidhuber, Long Short-Term Memory. <https://www.bioinf.jku.at/publications/older/2604.pdf>`_
inputs:
x:
doc: Input N-D array with shape :math:`(T, B, I)`.
h:
doc: Input N-D array with shape :math:`(L, D, B, H)`.
c:
doc: Input N-D array with shape :math:`(L, D, B, H)`.
weight_l0:
doc: weight parameters for the first layer. Shape is :math:`(D, 4, H, I +
H)`.
parameter: true
weight:
doc: weight parameters for the second layer and above. Shape is :math:`(L-1,
D, 4, H, D * H + H)`.
optional: true
parameter: true
bias:
doc: Bias vector (:math:`L`). Shape is :math:`(L, D, 4, H)`.
optional: true
parameter: true
arguments:
num_layers:
doc: Number of layers in the network. If set to 1, only the weights for the
first layer will be invoked. Default is 1.
type: int64
default: '1'
dropout:
doc: Dropout ratio applied to parameters. Default is 0.0.
type: float
default: 0.0
bidirectional:
doc: If True, bidirecitonal computation will be performed in each layer. Default
is False.
type: bool
default: 'False'
training:
doc: Backpropagation will be performed only when it is True. Default is True.
type: bool
default: 'True'
outputs:
y:
doc: Output :math:`y` with shape :math:`(T, B, D * H)`
h_n:
doc: Output :math:`h_n` with shape :math:`(L, D, B, H)`
c_n:
doc: Output :math:`c_n` with shape :math:`(L, D, B, H)`
function_ids:
ifBB: 242
c_runtime: not support
GRU:
snake_name: gru
doc: |2
N-Step GRU layer.
.. math::
{\mathbf r_t} = {\mathbf \sigma}( {\mathbf W_r} *{\mathbf x_t} + {\mathbf U_r}* {\mathbf h_{(t-1)}} + {\mathbf b_r})\\
{\mathbf z_t} = {\mathbf \sigma}( {\mathbf W_z} *{\mathbf x_t} + {\mathbf U_z}* {\mathbf h_{(t-1)}} + {\mathbf b_z})\\
{\mathbf n_t} = {\mathbf \tanh}( {\mathbf W_n}{\mathbf x_t}+ {\mathbf b_{in}}+ {\mathbf r_n}( {\mathbf U_n}{\mathbf h_{t-1}}+ {\mathbf b_{hn}})) \\
{\mathbf h_t} = (1- {\mathbf z_t})\odot {\mathbf n_t} + {\mathbf z_t}{\mathbf h_{t-1}}.
We use the following notations to describe the inputs and outputs below.
:math:`T`: sequcne length, :math:`B`: batch size, :math:`I`: input size, :math:`L`: number of layers, :math:`D`: number of directions, can be either 1 or 2, :math:`H`: hidden size.
References:
* `K. cho et al., Learning Phrases Representations using RNN Encoder-Decoder for Statistical Machine Translation. <https://www.aclweb.org/anthology/D14-1179>`_
inputs:
x:
doc: Input N-D array with shape :math:`(T, B, I)`.
h:
doc: Input N-D array with shape :math:`(L, D, B, H)`.
weight_l0:
doc: weight parameters for the first layer. Shape is :math:`(D, 3, H, I +
H)`.
parameter: true
weight:
doc: weight parameters for the second layer and above. Shape is :math:`(L-1,
D, 3, H, D * H + H)`.
optional: true
parameter: true
bias:
doc: Bias vector (:math:`L`). Shape is :math:`(L, D, 4, H)`.
optional: true
parameter: true
arguments:
num_layers:
doc: Number of layers in the network. If set to 1, only the weights for the
first layer will be invoked. Default is 1.
type: int64
default: '1'
dropout:
doc: Dropout ratio applied to parameters. Default is 0.0.
type: float
default: 0.0
bidirectional:
doc: If True, bidirecitonal computation will be performed in each layer. Default
is False.
type: bool
default: 'False'
training:
doc: Backpropagation will be performed only when it is True. Default is True.
type: bool
default: 'True'
outputs:
y:
doc: Output :math:`y` with shape :math:`(T, B, D * H)`
h_n:
doc: Output :math:`h_n` with shape :math:`(L, D, B, H)`
function_ids:
ifBB: 243
c_runtime: not support
Convolution:
snake_name: convolution
doc: |2
N-D Convolution with bias.
See references for dilated convolution (a.k.a. atrous convolution).
References:
* `Chen et al., DeepLab: Semantic Image Segmentation with Deep Convolutional
Nets, Atrous Convolution, and Fully Connected CRFs.
<https://arxiv.org/abs/1606.00915>`_
* `Yu et al., Multi-Scale Context Aggregation by Dilated Convolutions.
<https://arxiv.org/abs/1511.07122>`_
Note:
Convolution is a computationally intensive operation that
should preferrably be run with the `cudnn` backend. NNabla
then uses CuDNN library functions to determine and cache the
fastest algorithm for the given set of convolution parameters,
which results in additional memory consumption which may pose
a problem for GPUs with insufficient memory size. In that
case, the `NNABLA_CUDNN_WORKSPACE_LIMIT` environment variable
can be used to restrict the choice of algorithms to those that
fit the given workspace memory limit, expressed in bytes. In
some cases it may also be desired to restrict the automatic
search to algorithms that produce deterministic (reproducable)
results. This can be requested by setting the the environment
variable `NNABLA_CUDNN_DETERMINISTIC` to a non-zero value.
inputs:
x:
doc: :math:`(B + 1 + N)`-D array (:math:`M_1 \times ... \times M_B \times
C \times L_1 \times ... \times L_N`).
weight:
doc: :math:`(2 + N)`-D array (:math:`C' \times C \times K_1 \times ... \times
K_N`).
parameter: true
bias:
doc: Bias vector (:math:`C'`).
optional: true
parameter: true
arguments:
base_axis:
doc: base axis :math:`B`.
type: int64
default: '1'
pad:
doc: Padding sizes for dimensions.
type: Shape
default: (0,) * (len(x.shape) - (base_axis+1))
stride:
doc: Stride sizes for dimensions.
type: Shape
default: (1,) * (len(x.shape) - (base_axis+1))
dilation:
doc: Dilation sizes for dimensions.
type: Shape
default: (1,) * (len(x.shape) - (base_axis+1))
group:
doc: Number of groups of channels. This makes the connection across channels
sparser, by grouping connections along the mapping direction.
type: int64
default: '1'
outputs:
y:
doc: |2
:math:`(B + 1 + N)`-D array (:math:`M_1 \times ... \times M_B \times C' \times L'_1 \times ... \times L'_N`).
A spatial size of the output is calculated as
.. math::
L'_i = \frac{L_i + 2 p_i - d_i (k_i - 1) - 1}{s_i} + 1,
where :math:`L_i` is the spatial size, :math:`p_i` is the padding, :math:`d_i` is the dilation, :math:`k_i` is the kernel size, and :math:`s_i` is the stride for :math:`i`-th spatial dimension. The same calculation can also be applied to the other spatial dimensions.
function_ids:
iiIiIiIi: 1
c_runtime: support
DepthwiseConvolution:
snake_name: depthwise_convolution
doc: |2
N-D Depthwise Convolution with bias.
References:
* `F. Chollet: Chollet, Francois. "Xception: Deep Learning with Depthwise Separable Convolutions.
<https://arxiv.org/abs/1610.02357>`_
inputs:
x:
doc: :math:`(B + 1 + N)`-D array (:math:`M_1 \times ... \times M_B \times
C \times L_1 \times ... \times L_N`).
weight:
doc: :math:`(1 + N)`-D array (:math:`C \times K_1 \times ... \times K_N`).
parameter: true
bias:
doc: Bias vector (:math:`C`).
optional: true
parameter: true
arguments:
base_axis:
doc: base axis :math:`B`.
type: int64
default: '1'
pad:
doc: Padding sizes for dimensions.
type: Shape
default: (0,) * (len(x.shape) - (base_axis+1))
stride:
doc: Stride sizes for dimensions.
type: Shape
default: (1,) * (len(x.shape) - (base_axis+1))
dilation:
doc: Dilation sizes for dimensions.
type: Shape
default: (1,) * (len(x.shape) - (base_axis+1))
multiplier:
doc: Number of output feature maps per input feature map.
type: int64
default: '1'
outputs:
y:
doc: |2
:math:`(B + 1 + N)`-D array (:math:`M_1 \times ... \times M_B \times C' \times L'_1 \times ... \times L'_N`).
The output map size :math:`C'` is :math:`C` multiplied by :math:`m`
.. math::
C' = m \times C,
where :math:`m` is the multiplier.
A spatial size of the output is calculated as
.. math::
L'_i = \frac{L_i + 2 p_i - d_i (k_i - 1) - 1}{s_i} + 1,
where :math:`L_i` is the spatial size, :math:`p_i` is the padding, :math:`d_i` is the dilation, :math:`k_i` is the kernel size, and :math:`s_i` is the stride for :math:`i`-th spatial dimension. The same calculation can also be applied to the other spatial dimensions.
function_ids:
iiIiIiIi: 2
c_runtime: support
Deconvolution:
snake_name: deconvolution
doc: |2
N-D deconvolution, also known as transposed convolution, with bias operates backward convolution (derivative of the output w.r.t. the input) plus channel-wise learned bias.
The weights are specified in the same manner as :meth:`~nnabla.functions.convolution` , as if it was an ordinary convolution function.
The forward operation of :meth:`~nnabla.functions.deconvolution` will then be operationally equivalent to the backward pass of :meth:`~nnabla.functions.convolution` .
Therefore, the number of input channels (can be seen as output channels of forward convolution) is specified in the first dimension, and the number of the output channels divided by the number of groups is specified in the second dimension.
inputs:
x:
doc: :math:`(B + 1 + N)`-D array (:math:`M_1 \times ... \times M_B \times
C \times L_1 \times ... \times L_N`).
weight:
doc: :math:`(2 + N)`-D array (:math:`C' \times C \times K_1 \times ... \times
K_N`).
parameter: true
bias:
doc: Bias vector (:math:`C'`).
optional: true
parameter: true
arguments:
base_axis:
doc: base axis :math:`B`.
type: int64
default: '1'
pad:
doc: Padding sizes for dimensions.
type: Shape
default: (0,) * (len(x.shape) - (base_axis+1))
stride:
doc: Stride sizes for dimensions.
type: Shape
default: (1,) * (len(x.shape) - (base_axis+1))
dilation:
doc: Dilation sizes for dimensions.
type: Shape
default: (1,) * (len(x.shape) - (base_axis+1))
group:
doc: Number of groups of channels. This makes the connection across channels
sparser, by grouping connections along the mapping direction.
type: int64
default: '1'
outputs:
y:
doc: |2
:math:`(B + 1 + N)`-D array (:math:`M_1 \times ... \times M_B \times C' \times L'_1 \times ... \times L'_N`).
A spatial size of the output is calculated as
.. math::
L'_i =s_i (L_i - 1) - 2 p_i + d_i (k_i - 1) + 1,
where :math:`s_i` is the stride, :math:`L_i` is the spatial size, :math:`p_i` is the padding, :math:`d_i` is the dilation, and :math:`k_i` is the kernel size for :math:`i`-th spatial dimension. The same calculation can also be applied to the other spatial dimensions.
function_ids:
iiIiIiIi: 3
c_runtime: support
DepthwiseDeconvolution:
snake_name: depthwise_deconvolution
doc: |2
Depthwise deconvolution computes the transposed depthwise convolution with bias for one-dimensional and two-dimensional input data.
inputs:
x:
doc: :math:`(B + 1 + N)`-D array (:math:`M_1 \times ... \times M_B \times
C \times L_1 \times ... \times L_N`).
weight:
doc: :math:`(1 + N)`-D array (:math:`C \times K_1 \times ... \times K_N`).
parameter: true
bias:
doc: Bias vector (:math:`C`).
optional: true
parameter: true
arguments:
base_axis:
doc: base axis :math:`B`.
type: int64
default: '1'
pad:
doc: Padding sizes for dimensions.
type: Shape
default: (0,) * (len(x.shape) - (base_axis+1))
stride:
doc: Stride sizes for dimensions.
type: Shape
default: (1,) * (len(x.shape) - (base_axis+1))
dilation:
doc: Dilation sizes for dimensions.
type: Shape
default: (1,) * (len(x.shape) - (base_axis+1))
divisor:
doc: Number of input feature maps per output feature map.
type: int64
default: '1'
outputs:
y:
doc: |2
:math:`(B + 1 + N)`-D array (:math:`M_1 \times ... \times M_B \times C' \times L'_1 \times ... \times L'_N`).
The output map size :math:`C'` is :math:`C` multiplied by :math:`m`
.. math::
C' = \frac{C}{d},
where :math:`d` is the divisor.
A spatial size of the output is calculated as
.. math::
L'_i =s_i (L_i - 1) - 2 p_i + d_i (k_i - 1) + 1,
where :math:`s_i` is the stride, :math:`L_i` is the spatial size, :math:`p_i` is the padding, :math:`d_i` is the dilation, and :math:`k_i` is the kernel size for :math:`i`-th spatial dimension. The same calculation can also be applied to the other spatial dimensions.
function_ids:
iiIiIiIi: 4
c_runtime: not support
MaxPooling:
snake_name: max_pooling
doc: |2
Max pooling. It pools the maximum values inside the scanning kernel:
.. math::
y_{i_1, i_2} = \max_{k_1, k_2 \in K} (x_{i_1 + k_1, i_2 + k_2})
where :math:`x_{i_1 + k_1, i_2 + k_2}` is the input and :math:`y_{i_1, i_2}` is the output.
inputs:
x:
doc: Input variable.
arguments:
kernel:
doc: Kernel sizes for each spatial axis.
type: Shape
stride:
doc: Subsampling factors for each spatial axis.
type: Shape
default: kernel
ignore_border:
doc: If false, kernels covering borders are also considered for the output.
type: bool
default: 'True'
pad:
doc: Border padding values for each spatial axis. Padding will be added both
sides of the dimension.
type: Shape
default: (0,) * len(kernel)
outputs:
y:
doc: Maximum values variable
function_ids:
iIiIBiI: 5
c_runtime: support
AveragePooling:
snake_name: average_pooling
doc: |2
Average pooling. It pools the averaged values inside the scanning kernel:
.. math::
y_{i_1, i_2} = \frac{1}{K_1 K_2} \sum_{k1} \sum_{k2} x_{i_1 + k_1, i_2 + k_2}
where :math:`x_{i_1 + k_1, i_2 + k_2}` is the input and :math:`y_{i_1, i_2}` is the output.
inputs:
x:
doc: Input variable.
arguments:
kernel:
doc: Kernel sizes for each spatial axis.
type: Shape
stride:
doc: Subsampling factors for each spatial axis.
type: Shape
default: kernel
ignore_border:
doc: If false, kernels covering borders are also considered for the output.
type: bool
default: 'True'
pad:
doc: Border padding values for each spatial axis. Padding will be added both
sides of the dimension.
type: Shape
default: (0,) * len(kernel)
including_pad:
doc: If true, border padding values are considered for the output.
type: bool
default: 'True'
outputs:
y:
doc: Average values variable
function_ids:
iIiIBiIB: 6
c_runtime: support
GlobalAveragePooling:
snake_name: global_average_pooling
doc: |
.. WARNING::
This function is experimental support, so please do not actively use it.
Global average pooling. It pools an averaged value from the whole image
inputs:
x:
doc: Input variable.
outputs:
y:
doc: Average values variable
function_ids:
Empty: 7
c_runtime: not support
SumPooling:
snake_name: sum_pooling
doc: |2
Sum pooling. It pools the summed values inside the scanning kernel:
.. math::
y_{i_1, i_2} = \sum_{k1} \sum_{k2} x_{i_1 + k_1, i_2 + k_2}
where :math:`x_{i_1 + k_1, i_2 + k_2}` is the input and :math:`y_{i_1, i_2}` is the output.
inputs:
x:
doc: Input variable.
arguments:
kernel:
doc: Kernel sizes for each spatial axis.
type: Shape
stride:
doc: Subsampling factors for each spatial axis.
type: Shape
default: kernel
ignore_border:
doc: If false, kernels covering borders are also considered for the output.
type: bool
default: 'True'
pad:
doc: Border padding values for each spatial axis. Padding will be added both
sides of the dimension.
type: Shape
default: (0,) * len(kernel)
outputs:
y:
doc: Summed values variable
function_ids:
iIiIBiI: 8
c_runtime: support
Unpooling:
snake_name: unpooling
doc: |2
Inverse operation of pooling. It spreads the input values:
.. math::
y_{k_1 i_1 + j_1, k_2 i_2 + j_2} = x_{i_1, i_2}
where :math:`_{i_1, i_2}` is the input and :math:`y_{k_1 i_1 + j_1, k_2 i_2 + j_2}` is the output.
inputs:
x:
doc: Input variable.
arguments:
kernel:
doc: Kernel sizes for each spatial axis.
type: Shape
outputs:
y:
doc: Spread values variable
function_ids:
iI: 9
c_runtime: support
Embed:
snake_name: embed
doc: |2
Embed slices of a matrix/tensor with indexing array/tensor.
inputs:
x0:
doc: Indices with shape :math:`(I_0, ..., I_N)`
template: TI
w:
doc: Weights with shape :math:`(W_0, ..., W_M)`
parameter: true
outputs:
y:
doc: Output with shape :math:`(I_0, ..., I_N, W_1, ..., W_M)`
function_ids:
Empty: 10
c_runtime: not support
Neural Network Activation Functions:
Sigmoid:
snake_name: sigmoid
doc: |2
Element-wise sigmoid function.
.. math::
f(x) = \frac{1}{1 + \exp(-x)},
inputs:
x:
doc: Input
outputs:
y:
doc: Output
function_ids:
Empty: 11
c_runtime: support
Swish:
snake_name: swish
doc: |2-
Element-wise swish function, by Ramachandran et al. (2017).
.. math::
y_i = \frac{x_i}{1 + \exp(-x_i)},
References:
* `Prajit Ramachandran, Barret Zoph, and Quoc V. Le, Swish: a Self-Gated Activation Function, arXiv:1710.05941 [cs.NE]
<https://arxiv.org/abs/1710.05941>`_
inputs:
x:
doc: Input
outputs:
y:
doc: Output
function_ids:
Empty: 12
c_runtime: support
Tanh:
snake_name: tanh
doc: |2
Element-wise hyperbolic tangent (tanh) function.
.. math::
y_i = \tanh (x_i)
inputs:
x:
doc: N-D array
outputs:
y:
doc: N-D array with the same shape as x
function_ids:
Empty: 13
c_runtime: support
ReLU:
snake_name: relu
doc: |2
Element-wise Rectified Linear Unit (ReLU) function.
.. math::
y_i = \max (0, x_i)
inputs:
x:
doc: N-D array
arguments:
inplace:
doc: The output array is shared with the input array if True.
type: bool
default: 'False'
outputs:
y:
doc: N-D array with the same shape as x
function_ids:
B: 14
c_runtime: support
LeakyReLU:
snake_name: leaky_relu
doc: |2+
Element-wise Leaky Rectified Linear Unit (ReLU) function.
It is defined as:
.. math::
y_i = \alpha * \min(0, x_i) + \max (0, x_i)
inputs:
x:
doc: N-D array
arguments:
alpha:
doc: The slope value multiplied to negative numbers. :math:`\alpha` in the
definition.
type: float
default: '0.1'
inplace:
doc: The output array is shared with the input array if True.
type: bool
default: 'False'
outputs:
y:
doc: N-D array with the same shape as x
function_ids:
f: 15
fB: 128
c_runtime: support
Softmax:
snake_name: softmax
doc: |2
Softmax normalization. Calculates
.. math::
y_i = \frac{\exp(x_i)}{\sum_j \exp(x_j)}
along the dimension specified by `axis`, where :math:`y_i` is the input and :math:`x_i` is the output.
inputs:
x:
doc: N-D array. Typically indicates a score.
arguments:
axis:
doc: Axis normalization is taken.
type: int64
default: len(x.shape) - 1
outputs:
y:
doc: N-D array with the same shape as x
function_ids:
i: 16
c_runtime: support
ELU:
snake_name: elu
doc: |2
Element-wise Exponential Linear Unit (ELU) function.
.. math::
y_i= \left\{
\begin{array}{ll}
x_i & (x > 0)\\
\alpha (\exp(x_i) - 1) & (x \leq 0)
\end{array} \right..
References:
* `Clevart et al., Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs).
<http://arxiv.org/abs/1511.07289>`_
inputs:
x:
doc: N-D array
arguments:
alpha:
doc: Coefficient for negative outputs. :math:`\alpha` in definition
type: double
default: '1.0'
outputs:
y:
doc: N-D array with the same shape as x
function_ids:
f: 17
c_runtime: support
SELU:
snake_name: selu
doc: |2
Element-wise Scaled Exponential Linear Unit (SELU) function by Klambauer et al. (2017).
.. math::
y_i= \lambda \left\{
\begin{array}{ll}
x_i & (x > 0)\\
\alpha (\exp(x_i) - 1) & (x \leq 0)
\end{array} \right..
The coefficients :math:`\lambda` and :math:`\alpha` default to the following values :math:`\lambda_{01}` and :math:`\alpha_{01}`, respectively, provided by Klambauer et al. (2017):
.. math::
\begin{array}{lll}
\lambda_{01} &=& \left( 1 - \operatorname{erfc}\left( \frac{1}{\sqrt{2}} \right) \sqrt{e} \right)
\sqrt{2 \pi} \\
&& \left(
2 \operatorname{erfc} \left( \sqrt{2} \right) e^2
+ \pi \operatorname{erfc}\left( \frac{1}{\sqrt{2}} \right)^2 e
\right. \\
&& \left.
- 2(2 + \pi) \operatorname{erfc} \left( \frac{1}{\sqrt{2}} \right) \sqrt{e}
+ \pi + 2
\right)^{-1/2} \\
&\approx& 1.0507 \\
\alpha_{01} &=& - \frac
{\sqrt {\frac {2}{\pi}}}
{\operatorname{erfc} \left( \frac{1}{\sqrt{2}} \right) \exp \left(\frac {1} {2} \right) - 1} \\
&\approx& 1.67326
\end{array}
References:
* `Klambauer, G., Unterthiner, T., Mayr, A., & Hochreiter, S. (2017).
Self-Normalizing Neural Networks. In Advances in Neural Information
Processing Systems (NIPS). <https://arxiv.org/abs/1706.02515>`_
inputs:
x:
doc: N-D array
arguments:
scale:
doc: The coefficient :math:`\lambda` in the definition.
type: double
default: '1.05070098735548'
alpha:
doc: The coefficient :math:`\alpha` in the definition.
type: double
default: '1.673263242354377'
outputs:
y:
doc: N-D array with the same shape as x
function_ids:
ff: 18
c_runtime: support
CReLU:
snake_name: crelu
doc: |2
Element-wise Concatenated Rectified Linear Unit (CReLU) function.
This function calculates the ReLU of :math:`x` and :math:`-x` , then concatenates the results together at a specified axis,
and returns the resulting array.
References:
* `Wenling Shang, Kihyuk Sohn, Diogo Almeida, Honglak Lee.
Understanding and Improving Convolutional Neural Networks
via Concatenated Rectified Linear Units.
<https://arxiv.org/abs/1603.05201>`_
inputs:
x:
doc: N-D array.
arguments:
axis:
doc: The ReLU activations of positive inputs and negative inputs are concatenated
at axis.
type: int64
default: '1'
outputs:
y:
doc: N-D array where axis dimension is doubled by concatenating.
function_ids:
i: 19
c_runtime: support
CELU:
snake_name: celu
doc: |2
Element-wise Concatenated Exponential Linear Unit (CELU) function.
Concatenates ELU outputs of positive and negative inputs together at specified axis.
inputs:
x:
doc: N-D array.
arguments:
alpha:
doc: Coefficient for negative outputs. :math:`\alpha` in definition.
type: double
default: '1.0'
axis:
doc: The ELU activations of positive inputs and negative inputs are concatenated
at axis.
type: int64
default: '1'
outputs:
y:
doc: N-D array where axis dimension is doubled by concatenating.
function_ids:
fi: 20
c_runtime: support
PReLU:
snake_name: prelu
doc: |2
Element-wise Parametrized Rectified Linear Unit function. Calculates:
.. math::
y_i = \max(0, x_i) + w_i \min(0, -x_i)
where negative slope :math:`w` is learned and can vary across channels (an
axis specified with `base_axis`).
inputs:
x0:
doc: (N-D array) Input
x1:
doc: (N-D array) Weights
arguments:
base_axis:
doc: Dimensions up to base_axis is treated as sample dimension.
type: int64
default: '1'
outputs:
y:
doc: N-D array.
function_ids:
i: 21
c_runtime: support
GELU:
snake_name: gelu
doc: |2
Gaussian Error Unit (GELU) function.
.. math::
GELU(x) = xP(X \leq x) = x \Phi (x)
which is approximated by
.. math::
GELU(x) = 0.5x (1 + \tanh ( \sqrt(2/\pi)(x + 0.044715x^3) ))
References:
* `Dan Hendrycks and Kevin Gimpel.
Gaussian Error Linera Units (GELUs).
<https://arxiv.org/abs/1606.08415>`_
inputs:
x:
doc: N-D array
outputs:
y:
doc: N-D array with the same shape as x
function_ids:
Empty: 245
c_runtime: not support