2020
10-08
10-08
keras分类模型中的输入数据与标签的维度实例
在《python深度学习》这本书中。一、21页mnist十分类导入数据集fromkeras.datasetsimportmnist(train_images,train_labels),(test_images,test_labels)=mnist.load_data()初始数据维度:>>>train_images.shape(60000,28,28)>>>len(train_labels)60000>>>train_labelsarray([5,0,4,...,5,6,8],dtype=uint8)数据预处理:train_images=train_images.reshape((60000,28*28))train_images=train_images.asty...
继续阅读 >
我就废话不多说了,大家还是直接看代码吧~注释讲解版:#Classifierexampleimportnumpyasnp#forreproducibilitynp.random.seed(1337)#fromkeras.datasetsimportmnistfromkeras.utilsimportnp_utilsfromkeras.modelsimportSequentialfromkeras.layersimportDense,Activationfromkeras.optimizersimportRMSprop#程序中用到的数据是经典的手写体识别mnist数据集#downloadthemnisttothepathifitisth...