The meaning of some python sentences

Just for the record, please skip it.

from future import

Introduce the features of the new version into the current version

Insert picture description here

Portal

.as_matrix()

Convert other forms to ndarray
Insert picture description here

assert

Used to set breakpoints:

Insert picture description here
Portal

isinstance

Used to determine the character type:

Insert picture description here
Portal

enumerate([scale, crop, composed]):

Select one by one from the array, and loop

(Select scale, crop, composed in turn)

Insert picture description here

.__ name __

Should be the name of the class

Insert picture description here
Insert picture description here

**in the transformed_sample**

Insert picture description here

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))

Insert picture description here

Portal

Portal

image[top: top + new_h,left: left + new_w]

Insert picture description here
即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

Insert picture description here

shuffle=True

Refers to the shuffle of each iteration

num_workers=4

Open 4 threads to import data

Portal-Brief Book

Insert picture description here
Insert picture description here
Insert picture description here

plt.ioff ()

Turn off the blocking mode of plt.show() (you must close the picture before you can continue to run the program)

Insert picture description here

Portal

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)

Portal
Insert picture description here

copy.deepcopy

copy.deepcopy is independent after copying. How the original data changes will not affect the copy copied to the clipboard-deep copy

Insert picture description here
Portal

Guess you like

Origin blog.csdn.net/weixin_41529093/article/details/112967666