Just for the record, please skip it.
Article Directory
- from __future__ import
- .as_matrix()
- assert
- isinstance
- enumerate([scale, crop, composed]):
- .__ name __
- **in the transformed_sample**
- image[top: top + new_h,left: left + new_w]
- The difference between ndarrays and Tensors
- torch.utils.data.DataLoader
- plt.ioff ()
- Keep
- The role of torchvision.utils.make_grid
- copy.deepcopy
from future import
Introduce the features of the new version into the current version
.as_matrix()
Convert other forms to ndarray
assert
Used to set breakpoints:
isinstance
Used to determine the character type:
enumerate([scale, crop, composed]):
Select one by one from the array, and loop
(Select scale, crop, composed in turn)
.__ name __
Should be the name of the class
**in the transformed_sample**
It seems to be a dictionary type using transformed_sample
(Or change transformed_sample into a dictionary type-(1,2,3)→('a':1,'b':2,'c':3))
image[top: top + new_h,left: left + new_w]
即image(xstart + xend, ystart: yend)
Is a slice selection of the image
The difference between ndarrays and Tensors
Tensors are GPU read, ndarrays are memory read;
Tensors are immutable, ndarrays are variable
torch.utils.data.DataLoader
batch_size=4
Network training uses 4 sets of pictures-labels, parallel training
shuffle=True
Refers to the shuffle of each iteration
num_workers=4
Open 4 threads to import data
plt.ioff ()
Turn off the blocking mode of plt.show() (you must close the picture before you can continue to run the program)
Keep
imshow(out, title=[class_names[x] for x in classes])
The role of torchvision.utils.make_grid
The effect is将若干幅图像拼成一幅图像
# 获取一批训练数据
inputs, classes = next(iter(dataloaders['train']))
# 批量制作网格
out = torchvision.utils.make_grid(inputs)
copy.deepcopy
copy.deepcopy is independent after copying. How the original data changes will not affect the copy copied to the clipboard-deep copy