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.5323 0.7914 0.8055 -1.5571 -2.7017 -2.1485 1.4615 0.0120 0.9736 -0.9444
#> 0.4322 1.8139 -1.2508 -0.2912 -0.5599 -1.5309 1.7730 -1.2344 0.4836 -0.3568
#> 0.4741 0.0986 0.3036 1.4667 -0.6151 -0.1850 -2.1041 -0.7848 0.0942 1.7105
#> 1.1324 -0.7944 1.5266 0.5180 1.7285 -0.8715 0.7018 0.2911 1.8261 0.0928
#> -1.1297 -1.5084 -1.5635 -0.3039 0.3328 -0.4635 -1.0578 -0.6043 -0.0493 1.3262
#> 1.1969 0.2623 -0.1365 0.6874 -0.8377 -1.0260 -0.3675 1.7943 1.1193 -0.0988
#> -1.3289 -1.9703 -1.2593 1.2596 1.2783 1.8747 0.9911 -0.4761 0.1253 0.5903
#> -0.9472 -0.9097 0.0755 1.3873 1.1577 1.0626 -0.1018 1.2210 1.4032 0.3106
#> -1.1479 -1.2686 0.6829 1.0225 -0.4061 1.0058 0.0912 -0.8357 0.0714 -0.7613
#> -0.4531 0.3183 0.1503 1.3292 -0.2573 -0.0188 -1.5015 -0.3813 1.0945 -2.1248
#> -0.0959 0.4481 -0.6593 0.9853 -2.7289 0.1699 -0.6961 -0.5189 1.0364 0.0701
#> 0.8283 2.5047 0.4121 -0.6449 0.8600 1.3818 -0.0772 -1.8232 -0.1946 -0.8324
#> -0.5144 0.4445 -0.0204 -0.1818 -0.8557 -0.2157 1.6438 -2.2822 -1.2997 0.0894
#> -0.6338 -1.5578 0.1349 -0.7951 2.3758 0.3265 -0.6223 -0.6363 -0.9099 0.6410
#> 0.8209 -0.6579 -0.5816 1.8266 -0.6944 1.1962 -1.9803 1.2401 -0.0454 -2.4813
#> -1.2920 1.0462 0.1010 0.4184 -1.4312 0.2113 0.6778 -0.3708 0.1104 0.3188
#> -0.3377 0.3693 -0.3925 -0.2370 0.7831 0.6065 0.1395 -0.4003 2.0919 -0.7659
#> 0.1570 0.4832 1.4433 -0.4278 -0.5198 0.5446 -1.0989 -0.9049 0.0595 -0.7692
#> -0.0463 -1.3909 2.7675 -2.1994 0.7258 -0.9248 1.3351 1.3713 -0.1426 0.1724
#> -0.4918 1.2205 1.0043 0.3490 -0.1135 1.4005 2.1771 0.2452 -1.0130 0.5716
#> -0.2040 -0.8590 1.0088 -0.1578 -1.5889 0.4635 -1.1594 -0.2269 0.3126 0.1363
#> -1.1458 1.9362 0.4537 1.2999 -0.6429 1.3710 0.5977 0.1056 -0.3668 -0.7516
#> -0.0165 -0.3694 -0.1787 0.5755 -0.6591 1.0324 -1.0115 0.0971 0.4780 -0.0292
#> 0.9075 -0.6972 0.6900 0.0666 0.3476 -0.7101 -0.0841 -0.5424 0.7682 1.2324
#> -1.0078 0.8806 -0.2856 0.2866 0.3267 1.4083 2.0584 0.4789 -0.9918 -1.3223
#> 2.0853 -0.6825 0.2140 1.0394 -1.2656 0.7614 -0.8907 0.3011 1.6871 0.6352
#> 0.2405 1.3308 -0.3534 1.0292 1.1903 0.8943 -1.2025 1.4763 -0.9065 -1.7503
#> 0.5954 -0.1114 -0.6051 0.4637 -0.9679 1.0432 -0.2765 -0.0136 1.4138 -1.0906
#> 0.0942 -3.2235 -1.1174 -0.9202 -0.6290 0.5714 -0.4955 2.7457 -0.2993 1.5302
#> -0.0372 1.4559 0.3616 -0.9499 1.2516 -1.4699 1.2853 -0.6512 0.4564 -0.0764
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{32,25} ]