当前位置:   article > 正文

python中利用Keras建几层卷积神经网络来做Kaggle猫狗识别_index=np.arange(2000)

index=np.arange(2000)
  1. import numpy as np
  2. np.random.seed(1336) # for reproducibility
  3. from keras.datasets import mnist
  4. from keras.datasets import cifar10
  5. from keras.models import Sequential
  6. from keras.layers import Dense, Dropout, Activation, Flatten
  7. from keras.layers import Convolution2D, MaxPooling2D
  8. from keras.utils import np_utils
  9. from keras import backend as K
  10. import h5py
  11. from PIL import Image
  12. import cv2
  13. import matplotlib.pyplot as pyplot
  14. # 全局变量
  15. batch_size = 20
  16. nb_classes = 2
  17. epochs = 20
  18. trainImagesNum = 4000
  19. testImagesNum = 2000
  20. # input image dimensions
  21. img_rows, img_cols = 128, 128
  22. # number of convolutional filters to use
  23. nb_filters = 128
  24. # size of pooling area for max pooling
  25. pool_size = (2, 2)
  26. # convolution kernel size
  27. kernel_size = (3, 3)
  28. X_train = np.zeros([2000, img_rows, img_cols, 3])
  29. X_test = np.zeros([2000, img_rows, img_cols, 3])
  30. print(type(X_train), X_train.shape)
  31. for i in range(2000):
  32. if (np.mod(i, 50) &#
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/261735
推荐阅读
相关标签
  

闽ICP备14008679号