instant # index of record day # day of month season # season (1: spring, 2: summer, 3: fall, 4: winter) yr # year (0: 2011, 1: 2012) mnth # month (1 to 12) hr # hour (0 to 23) holiday # holiday status weekday # day of the week workingday # working day status weathersit # weather situation # (1: clear, 2:mist, 3: light rain/snow, 4: heavy rain/snow) temp # temperature in C atemp # perceived temperature in C hum # humidity windspeed # windspeed casual # number of causal users registered # number of registered users cnt # count of rental bikes
data_dir = "image-cats/" filenames = [name for name in os.listdir(data_dir) if os.path.splitext(name) == '.png'] for i, filename inenumerate(filenames): img_arr = imageio.imread(filename) batch[i] = torch.transpose(torch.from_numpy(img_arr), 0, 2)
由于神经网络对0~1范围内的数值能够鞥有效的处理,所以一般会采用下面的处理方法:
1 2 3 4 5 6 7 8 9 10
# 直接处理 batch = batch.float() batch /= 255.0
# 对每个channel标准化 n_channels = batch.shape[1] for c inrange(n_channels): mean = torch.mean(batch[:, c]) std = torch.std(batch[:, c]) batch[:, c] = (batch[:, c] - mean) / std
Creation ops—Functions for constructing a tensor, such as ones and from_numpy
Indexing, slicing, joining, and mutating ops—Functions for changing the shape,
stride, or content of a tensor, such as transpose
Math ops—Functions for manipulating the content of the tensor through computations:
Pointwise ops—Functions for obtaining a new tensor by applying a function to each element independently, such as abs and cos
Reduction ops—Functions for computing aggregate values by iterating through tensors, such as mean, std, and norm
Comparison ops—Functions for evaluating numerical predicates over tensors, such as equal and max
Spectral ops—Functions for transforming in and operating in the frequency domain, such as stft and hamming_window
Other ops—Special functions operating on vectors, such as cross, or matrices, such as trace
BLAS and LAPACK ops—Functions that follow the BLAS (Basic Linear Algebra Subprograms) specification for scalar, vector-vector, matrix-vector, and matrix-matrix operations
Random sampling ops—Functions for generating values by drawing randomly
from probability distributions, such as randn and normal
Serialization ops—Functions for saving and loading tensors, such as load and
save
Parallelism ops—Functions for controlling the number of threads for parallel