In the above code second and third lines create a one-dimensional NumPy array x of length 4, using arange function and then reshapes it to a 2x2 array using reshape. 7th and 8th lines create a one-dimensional N
NumPy ones_like Function - Learn how to use the NumPy ones_like function to create an array of ones with the same shape and type as a given array. Explore examples and applications.
Similarly for ones_like, there is atorch.onesfunction available. Sorry, something went wrong. Copy link ContributorAuthor vadimkantorovcommentedOct 1, 2017 Sure, workarounds exist, an even easier one is:torch.autograd.Variable(torch.zeros_like(variable.data))(will respect CPU/GPU tensor placement...
Enviroment: Python 3.5.4 :: Anaconda custom (64-bit) pytorch 0.2.1 py35h24644ff_0.2.1cu80 peterjc123 couldn't find ones_like API.