使用image前需安装pillow
pip install Pillow
from tensorflow.python.keras.preprocessing.image import load_img, img_to_arraydef main(): img = load_img("./images/img01.jpg", target_size=[300,300]) img = img_to_array(img) print(img)if __name__ == "__main__": main()
#创建神经网络模型 model = Sequential([ Flatten(input_shape=(28,28)), Dense(128,activation=tf.nn.relu), Dense(10,activation=tf.nn.softmax) ])
model的一些属性
1)compile
loss:
2)fit
3)evaluate
神经网络和keras