return a random tensor with given shape Args: shape: shape of generated tensor device: device of generated tensor, default is cpu Returns: new tensor generated
(shape, device=get_default_device())
| 1815 | |
| 1816 | |
| 1817 | def random(shape, device=get_default_device()): |
| 1818 | ''' return a random tensor with given shape |
| 1819 | |
| 1820 | Args: |
| 1821 | shape: shape of generated tensor |
| 1822 | device: device of generated tensor, default is cpu |
| 1823 | |
| 1824 | Returns: |
| 1825 | new tensor generated |
| 1826 | ''' |
| 1827 | ret = Tensor(shape, device=device) |
| 1828 | ret.uniform(0, 1) |
| 1829 | return ret |
| 1830 | |
| 1831 | |
| 1832 | def zeros(shape, device=get_default_device()): |
nothing calls this directly
no test coverage detected