码迷,mamicode.com
首页 > 其他好文 > 详细

查看keras自动给文件夹标号

时间:2018-01-31 14:24:22      阅读:337      评论:0      收藏:0      [点我收藏+]

标签:tag   process   遍历   flat   size   batch   directory   from   flip   

 1 from tensorflow.contrib.keras.api.keras.preprocessing.image import ImageDataGenerator,img_to_array
 2 from tensorflow.contrib.keras.api.keras.models import Sequential
 3 from tensorflow.contrib.keras.api.keras.layers import Dense, Dropout, Activation, Flatten
 4 from tensorflow.contrib.keras.api.keras.layers import Conv2D, MaxPooling2D
 5 IMAGE_SIZE = 224
 6 img_rows= 224
 7 img_cols = 224
 8 # 训练图片大小
 9 epochs = 50#原来是50
10 # 遍历次数
11 batch_size = 32
12 # 批量大小
13 nb_train_samples = 256*2
14 # 训练样本总数
15 nb_validation_samples = 64*2
16 # 测试样本总数
17 train_data_dir = D:\\pycode\\learn\\data\\train_data\\
18 validation_data_dir = D:\\pycode\\learn\\data\\test_data\\
19 # 样本图片所在路径
20 FILE_PATH = age.h5
21 
22 train_datagen = ImageDataGenerator(
23     rescale=1. / 255,
24     horizontal_flip=True)
25 
26 test_datagen = ImageDataGenerator(rescale=1. / 255)
27 
28 train_generator = train_datagen.flow_from_directory(
29     train_data_dir,
30     target_size=(img_rows, img_cols),
31     batch_size=batch_size,
32     class_mode=categorical)
33 
34 validation_generator = test_datagen.flow_from_directory(
35     validation_data_dir,
36     target_size=(img_rows, img_cols),
37     batch_size=batch_size,
38     class_mode=categorical)
39 
40 # self.train = train_generator
41 # self.valid = validation_generator
42 print(validation_generator.class_indices)

技术分享图片

查看keras自动给文件夹标号

标签:tag   process   遍历   flat   size   batch   directory   from   flip   

原文地址:https://www.cnblogs.com/ansang/p/8391378.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!