For use with nn_sequential.
Shape
Input:
(*, S_start,..., S_i, ..., S_end, *), whereS_iis the size at dimensioniand*means any number of dimensions including none.Output:
(*, S_start*...*S_i*...S_end, *).
Examples
if (torch_is_installed()) {
input <- torch_randn(32, 1, 5, 5)
m <- nn_flatten()
m(input)
}
#> torch_tensor
#> Columns 1 to 10-0.1582 0.3884 -1.5632 0.7196 -0.2205 -1.7835 -0.6661 -1.7264 0.1628 -0.8758
#> -0.3737 -0.8115 -2.1005 0.0627 -0.3045 1.4506 -0.6305 1.2214 0.4031 -1.6824
#> 1.1758 -0.2578 1.1765 1.2256 0.1560 1.0866 0.4820 1.2603 -1.0302 0.6107
#> -0.7562 -0.7093 1.2052 0.4085 0.6378 1.0945 0.4667 -1.4432 0.0582 1.4798
#> 1.4722 0.4526 -0.9765 -0.6692 0.0418 1.0749 0.1325 0.3376 -0.3633 -1.5026
#> -1.0053 0.1446 -0.9803 0.9713 -0.2840 1.2749 -0.1783 0.5447 -1.1221 0.7340
#> -1.2648 0.9723 1.3332 -0.0302 -1.3932 -1.4991 -0.5200 0.4604 -1.3608 -1.3589
#> -0.2860 0.6719 -0.3339 -0.4222 -0.7139 0.4702 0.7931 0.7817 1.8080 0.5962
#> -0.7100 -0.8923 -0.8414 -0.3466 0.4923 1.5249 0.2795 -0.9273 -1.4795 0.7444
#> -0.3146 -0.2754 0.2926 -1.1596 0.9416 0.1110 -1.1205 -0.0890 0.9170 0.1624
#> 0.5040 -0.6209 -0.9784 0.5903 1.1282 0.3059 -0.8232 0.3094 2.3989 0.6833
#> -1.4770 0.5607 1.1840 0.1885 0.5920 -0.9191 -0.2165 0.8742 0.1817 0.4407
#> 0.2939 1.0579 -0.0253 0.6725 0.3855 1.3043 0.4780 -1.5100 1.8916 2.4278
#> -0.4487 -0.0617 -0.4693 0.5218 0.9512 0.4957 -0.8041 1.4929 1.1711 0.7071
#> -1.0296 0.4278 0.0945 1.2844 -0.7579 -0.6359 0.2901 0.8405 1.1472 0.9583
#> -0.9763 -0.5246 -0.7397 -0.9174 -0.0160 0.3348 0.1694 0.7063 -1.0036 0.2076
#> -1.0737 -0.4928 0.9640 -1.3019 -1.1108 -0.0942 -1.2271 -1.8290 -1.2871 0.0771
#> 0.2720 0.9329 -0.5919 -0.3185 -0.7456 0.6240 0.3579 0.0569 -0.8417 0.6781
#> 1.7852 -0.6460 -0.5031 -1.0371 -1.7999 -1.2863 0.3383 1.6757 0.6968 0.5534
#> -0.3035 0.5520 -0.0614 0.3078 -1.8848 0.7427 0.5582 1.0494 -0.1631 -0.3791
#> -0.3747 0.5794 0.8071 0.3757 -1.1108 1.1686 -0.2095 0.8592 -0.1231 1.0735
#> -0.8813 1.5114 0.2924 0.6129 -0.3881 -2.2573 0.5214 0.1533 -0.0338 0.8590
#> 1.2781 0.0083 -0.1498 -1.0427 0.7484 1.3472 0.9627 0.0325 1.1607 1.1250
#> -1.2298 1.9843 0.2211 -0.5208 1.9371 -0.3642 -1.7374 0.2583 -1.6167 1.4653
#> -0.4712 0.2489 -1.9094 0.2164 -0.0392 1.2666 -1.3128 0.1085 0.0182 -0.9435
#> 0.8778 0.8302 -0.6882 0.9876 -1.6937 -1.1158 0.3376 0.3564 1.3662 -0.7732
#> -0.6029 -0.5634 -0.8599 0.2626 -0.2676 0.4334 1.5757 0.6957 -0.9872 -0.5347
#> -0.5906 0.4191 0.6298 -0.7377 -0.6402 -1.8309 -0.0990 -0.8398 -0.7977 -0.5158
#> 0.8678 -0.5494 1.0362 -0.5457 1.0546 0.2354 -0.9924 -0.5687 -2.5281 -0.0860
#> -1.8493 -1.8100 0.1872 0.6671 0.9744 -0.3209 0.3568 0.5125 -1.2613 -0.9642
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{32,25} ]