February 2018
Intermediate to advanced
262 pages
6h 59m
English
A common thing to do with a tensor is to slice a portion of it. A simple example could be choosing the first five elements of a one-dimensional tensor; let's call the tensor sales. We use a simple notation, sales[:slice_index] where slice_index represents the index where you want to slice the tensor:
sales = torch.FloatTensor([1000.0,323.2,333.4,444.5,1000.0,323.2,333.4,444.5])sales[:5] 1000.0000 323.2000 333.4000 444.5000 1000.0000[torch.FloatTensor of size 5]sales[:-5] 1000.0000 323.2000 333.4000[torch.FloatTensor of size 3]
Let's do more interesting things with our panda image, such as see what the panda image looks like when only one channel is chosen and see how to select the face of the panda.
Here, we select only one ...
Read now
Unlock full access