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.8104 -0.0914 -0.4423 0.5863 0.1626 0.5828 1.7240 -0.7224 1.7073 1.3518
#> -0.0120 2.5178 -0.4608 -0.8758 0.7601 -0.8613 -0.9570 -0.3058 -0.4570 -1.2632
#> -0.6387 0.2717 -0.0912 -2.4446 1.4806 -0.9752 0.3317 -0.6550 -1.0678 0.9427
#> 3.1015 1.9879 -0.9904 1.1056 1.1225 0.5945 -1.1645 0.4439 0.7604 -0.9997
#> -0.4676 1.7311 -1.1417 -0.7887 -1.3445 -1.1611 1.7931 -0.9727 0.7663 -0.6082
#> 1.6576 -1.3594 0.3619 0.9419 -2.1576 0.0192 -0.3371 0.5797 0.5085 -0.5162
#> -2.1523 0.0172 2.0659 2.2679 -0.6114 -0.9686 0.0688 0.7164 0.3410 0.5693
#> 0.4539 0.3028 -0.4356 1.2279 0.2949 -2.0394 0.3362 0.3233 0.5873 1.2793
#> 0.4834 1.1629 -0.4147 -0.8300 -0.0789 -0.8678 1.1221 0.3472 0.1410 -0.1633
#> -0.2674 -1.8722 0.9762 -0.3134 1.0460 0.9740 -0.9856 -0.7686 0.6419 -1.1644
#> 0.2253 0.8690 -0.0071 -0.4174 -0.2943 0.1769 -1.3238 -2.0311 0.4683 -1.9910
#> -0.7801 -0.4658 0.8625 -1.1303 1.3085 -0.1448 0.2263 1.3152 0.2425 1.5708
#> 0.5358 0.8737 -1.0028 0.2378 0.5101 1.4116 1.3122 0.9222 -1.3725 0.7881
#> -0.6620 0.7859 -0.3844 1.5155 -0.5652 -0.9500 0.6151 0.5171 1.9837 0.4216
#> 0.7974 0.9060 0.8258 -1.1261 -0.3789 0.2266 -1.2203 -0.4612 -1.7167 0.4852
#> -0.4058 -0.1868 -0.1523 0.5719 -0.7646 0.8701 -0.2197 0.8481 0.9949 0.3844
#> -0.0416 1.4414 0.1692 -2.3028 1.7395 -0.5469 0.8446 0.5517 1.4043 1.5092
#> 1.5822 -1.5954 0.3805 0.1196 0.2452 -0.0165 0.5087 1.8560 -0.5038 1.5910
#> 0.1713 -0.3196 1.0050 0.0885 0.6135 0.7950 -0.7254 -0.3162 2.4214 -0.6895
#> -0.0421 0.4793 0.2866 1.5065 -1.0660 0.0944 -0.2520 -0.7674 0.6975 -0.8716
#> 0.4894 0.7652 1.3019 0.2195 -1.1916 0.7170 0.0827 0.3882 0.6889 1.7546
#> -0.4560 0.5201 1.0093 -0.7073 0.1547 -1.1667 -1.6847 0.7212 0.6857 2.1776
#> 0.7121 0.0216 -1.0913 1.3827 -0.4474 -0.1032 -0.2149 -1.1370 0.8960 -1.0847
#> -1.2223 0.2798 -0.0202 -1.3249 0.1757 1.0660 -1.2374 -0.6866 0.2780 -0.5416
#> 0.1644 -0.8610 0.3096 0.7323 0.3112 1.2701 -0.5677 0.0162 2.2528 -0.3297
#> -0.0842 -0.2046 1.5343 -0.6973 0.0556 -0.1630 -1.0454 -0.0599 0.7428 -0.1916
#> 0.6888 -0.1744 -0.9284 1.3919 0.2492 0.2055 0.1522 0.6777 1.2069 -1.4883
#> -2.1371 0.8966 0.4668 -1.0719 -1.3211 -0.4492 0.1347 0.9377 -1.1431 0.4708
#> 0.8042 -0.7704 -0.8744 -0.3701 2.0455 -0.6858 0.4338 0.4547 1.1861 -0.0584
#> 2.8928 1.0297 1.1625 0.5498 -0.4573 0.5378 0.8757 0.6072 0.1675 -0.2217
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{32,25} ]