x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols) x_test =
x_test.reshape(x_test.shape[0], 1, img_rows, img_cols) from numpy import * l =
zeros((5,4))# Build a 5*4 Zero matrix of for i in range(5):# Assign a value to the matrix for j in range(4): l[i][j] =
i * 5 + j print(l)# Print assigned matrix print(shape(l))# output l Column value of print(l.shape[0])# output l Row value of
print(l.shape[1])# output l Column values for
python Image reading reshape Problems in size
#coding=utf-8 import matplotlib.pyplot as plt import matplotlib.image as
mimage image=mimage.imread('lala.jpg') print image.shape # show a picture
image=image.reshape(1,-1) #-1 Is the automatic inference of dimensions based on the size of the array
# If the image=image.reshape In a row , Respectively R a block , G block ,B a block # t=imgX1[222,:].reshape(3,32,32)
# print('t= ' ,t.shape) # image=np.transpose(t,(1,2,0))
image=image.reshape(1186,1920,3) print(image.shape) plt.imshow(image)
plt.axis('off') plt.show()
/ If you convert a floating-point number to an integer , The decimal part is truncated In [7]: arr2 = np.array([1.1, 2.2, 3.3, 4.4, 5.3221])
In [8]: arr2 Out[8]: array([ 1.1 , 2.2 , 3.3 , 4.4 , 5.3221]) // View current data type In
[9]: arr2.dtype Out[9]: dtype('float64') // shifting clause float -> int In [10]:
arr2.astype(np.int32) Out[10]: array([1, 2, 3, 4, 5], dtype=int32) Data type conversion
x_train = x_train.astype('float32') x_test = x_test.astype('float32')
# data normalization (0,1) x_train /= 255 x_test /= 255

©2019-2020 Toolsou All rights reserved,
What are the protection measures for website security ? Talking about uni-app Page value transfer problem Remember once EventBus Project issues caused by memory leaks I've been drinking soft water for three years ? What is the use of soft water and water softener Time conversion front desk will 2020-07-17T03:07:02.000+0000 Into 2020-07-17 11:07:02 Chuan Shen Count the number of letters (java Language implementation ) Time format 2020-01-13T16:00:00.000Z Medium T and Z What do they mean , How to deal with it msf Generate Trojan horse attack android mobile phone The world's first free open source ERP Odoo Ubuntu The best development environment What's the difference in server prices ?