懒人专属
图像相关
from tensorflow.keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img
from tensorflow.keras.preprocessing import image
import numpy as np
img = load_img('D:\\myproject\\tensorflow2\\smile\\4.png', target_size = (28, 28), color_mode="grayscale")
array_i = img_to_array(img)
img = array_to_img(array_i)
new_array_i = np.reshape(array_i,(28,28))
数组相关
import numpy as np
x = numpy.zeros((28,28), dtype = float, order = 'C')
numpy.ones,numpy.empty
a = np.linspace(1,10,5,endpoint= True)
print(a)
b = np.linspace(1,10,5,endpoint= False)
print(b)
c = np.linspace(1,10,5,retstep = False)
print(c)
d = np.linspace(1,10,5,retstep = True)
print(d)
x = np.arange(5)
x = np.arange(10,20,2, dtype = float)
a = np.array([
[0,1,2],
[3,4,5],
[6,7,8]
])
b = np.array([
[10,11,12],
[13,14,15],
[16,17,18]
])
a.size
a.shape
new_a = np.apend(a, (28,28,1))
x = np.hstack((a,b))
x = np.concatenate((a,b),axis=1)
x = np.vstack((a,b))
x = np.concatenate((a,b),axis=0)