1 minute read

torch.linspace

함수형태

torch.linspace(start, end, steps, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False)  Tensor

사용방법

import torch

start_step = 0
end_step=300

x = torch.linspace(start_step, end_step, 200)
print(x)
print(x.shape)
  • start_step, end_step 범위 안에서 균등한 차이의 값 200개를 넣는다.
output:
tensor([  0.0000,   1.5075,   3.0151,   4.5226,   6.0302,   7.5377,   9.0452,
         10.5528,  12.0603,  13.5678,  15.0754,  16.5829,  18.0905,  19.5980,
         21.1055,  22.6131,  24.1206,  25.6281,  27.1357,  28.6432,  30.1508,
         31.6583,  33.1658,  34.6734,  36.1809,  37.6884,  39.1960,  40.7035,
         42.2111,  43.7186,  45.2261,  46.7337,  48.2412,  49.7487,  51.2563,
         52.7638,  54.2714,  55.7789,  57.2864,  58.7940,  60.3015,  61.8090,
         63.3166,  64.8241,  66.3317,  67.8392,  69.3467,  70.8543,  72.3618,
         73.8693,  75.3769,  76.8844,  78.3920,  79.8995,  81.4070,  82.9146,
         84.4221,  85.9296,  87.4372,  88.9447,  90.4523,  91.9598,  93.4673,
         94.9749,  96.4824,  97.9900,  99.4975, 101.0050, 102.5126, 104.0201,
        105.5276, 107.0352, 108.5427, 110.0503, 111.5578, 113.0653, 114.5729,
        116.0804, 117.5879, 119.0955, 120.6030, 122.1106, 123.6181, 125.1256,
        126.6332, 128.1407, 129.6482, 131.1558, 132.6633, 134.1709, 135.6784,
        137.1859, 138.6935, 140.2010, 141.7085, 143.2161, 144.7236, 146.2312,
        147.7387, 149.2462, 150.7538, 152.2613, 153.7688, 155.2764, 156.7839,
        158.2915, 159.7990, 161.3065, 162.8141, 164.3216, 165.8291, 167.3367,
        168.8442, 170.3518, 171.8593, 173.3668, 174.8744, 176.3819, 177.8894,
        179.3970, 180.9045, 182.4120, 183.9196, 185.4271, 186.9347, 188.4422,
        189.9497, 191.4573, 192.9648, 194.4724, 195.9799, 197.4874, 198.9950,
        200.5025, 202.0100, 203.5176, 205.0251, 206.5327, 208.0402, 209.5477,
        211.0553, 212.5628, 214.0703, 215.5779, 217.0854, 218.5930, 220.1005,
        221.6080, 223.1156, 224.6231, 226.1306, 227.6382, 229.1457, 230.6533,
        232.1608, 233.6683, 235.1759, 236.6834, 238.1909, 239.6985, 241.2060,
        242.7136, 244.2211, 245.7286, 247.2362, 248.7437, 250.2513, 251.7588,
        253.2663, 254.7739, 256.2814, 257.7889, 259.2965, 260.8040, 262.3116,
...
        274.3719, 275.8794, 277.3869, 278.8945, 280.4020, 281.9095, 283.4171,
        284.9246, 286.4322, 287.9397, 289.4472, 290.9548, 292.4623, 293.9698,
        295.4774, 296.9849, 298.4925, 300.0000])
torch.Size([200])

Categories:

Updated: