質問編集履歴

6

文字数制限

2020/07/14 07:23

投稿

koukiten
koukiten

スコア6

test CHANGED
File without changes
test CHANGED
@@ -190,17 +190,7 @@
190
190
 
191
191
  path_four = path +'/Dataset/four'
192
192
 
193
- path_five = path +'/Dataset/five'
193
+
194
-
195
- path_six = path +'/Dataset/six'
196
-
197
- path_seven= path +'/Dataset/seven'
198
-
199
- path_eight= path +'/Dataset/eight'
200
-
201
- path_nine = path +'/Dataset/nine'
202
-
203
- path_zero = path +'/Dataset/zero'
204
194
 
205
195
 
206
196
 
@@ -212,17 +202,7 @@
212
202
 
213
203
  file_4=glob.glob(path_four +'/*.jpg')
214
204
 
215
- file_5=glob.glob(path_five +'/*.jpg')
205
+
216
-
217
- file_6=glob.glob(path_six +'/*.jpg')
218
-
219
- file_7=glob.glob(path_seven +'/*.jpg')
220
-
221
- file_8=glob.glob(path_eight +'/*.jpg')
222
-
223
- file_9=glob.glob(path_nine +'/*.jpg')
224
-
225
- file_0=glob.glob(path_zero +'/*.jpg')
226
206
 
227
207
 
228
208
 
@@ -392,28 +372,6 @@
392
372
 
393
373
 
394
374
 
395
- load_dir_5(path_five,5)
396
-
397
-
398
-
399
- load_dir_6(path_six,6)
400
-
401
-
402
-
403
- load_dir_7(path_seven,7)
404
-
405
-
406
-
407
- load_dir_8(path_eight,8)
408
-
409
-
410
-
411
- load_dir_9(path_nine,9)
412
-
413
-
414
-
415
- load_dir_0(path_zero,0)
416
-
417
375
 
418
376
 
419
377
  x=np.array(x)

5

書籍の改善

2020/07/14 07:23

投稿

koukiten
koukiten

スコア6

test CHANGED
File without changes
test CHANGED
@@ -226,6 +226,50 @@
226
226
 
227
227
 
228
228
 
229
+ print(len(file_1))
230
+
231
+ print(len(file_2))
232
+
233
+ print(len(file_3))
234
+
235
+ print(len(file_4))
236
+
237
+ print(len(file_5))
238
+
239
+ print(len(file_6))
240
+
241
+ print(len(file_7))
242
+
243
+ print(len(file_8))
244
+
245
+ print(len(file_9))
246
+
247
+ print(len(file_0))
248
+
249
+
250
+
251
+ #出力
252
+
253
+ 26
254
+
255
+ 20
256
+
257
+ 23
258
+
259
+ 21
260
+
261
+ 11
262
+
263
+ 19
264
+
265
+ 20
266
+
267
+ 16
268
+
269
+ 22
270
+
271
+ 22
272
+
229
273
 
230
274
 
231
275
 
@@ -328,137 +372,7 @@
328
372
 
329
373
 
330
374
 
331
- def load_dir_5(path,label):
375
+
332
-
333
-
334
-
335
- for i in file_5:
336
-
337
- img=cv2.imread(i)
338
-
339
- img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
340
-
341
- img=cv2.resize(img,in_size)
342
-
343
- img=img/255.0
344
-
345
- x.append(img)
346
-
347
- z.append(label)
348
-
349
- return [x,z]
350
-
351
-
352
-
353
- def load_dir_6(path,label):
354
-
355
-
356
-
357
- for i in file_6:
358
-
359
- img=cv2.imread(i)
360
-
361
- img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
362
-
363
- img=cv2.resize(img,in_size)
364
-
365
- img=img/255.0
366
-
367
- x.append(img)
368
-
369
- z.append(label)
370
-
371
- return [x,z]
372
-
373
-
374
-
375
- def load_dir_7(path,label):
376
-
377
-
378
-
379
- for i in file_7:
380
-
381
- img=cv2.imread(i)
382
-
383
- img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
384
-
385
- img=cv2.resize(img,in_size)
386
-
387
- img=img/255.0
388
-
389
- x.append(img)
390
-
391
- z.append(label)
392
-
393
- return [x,z]
394
-
395
-
396
-
397
- def load_dir_8(path,label):
398
-
399
-
400
-
401
- for i in file_8:
402
-
403
- img=cv2.imread(i)
404
-
405
- img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
406
-
407
- img=cv2.resize(img,in_size)
408
-
409
- img=img/255.0
410
-
411
- x.append(img)
412
-
413
- z.append(label)
414
-
415
- return [x,z]
416
-
417
-
418
-
419
- def load_dir_9(path,label):
420
-
421
-
422
-
423
- for i in file_9:
424
-
425
- img=cv2.imread(i)
426
-
427
- img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
428
-
429
- img=cv2.resize(img,in_size)
430
-
431
- img=img/255.0
432
-
433
- x.append(img)
434
-
435
- z.append(label)
436
-
437
- return [x,z]
438
-
439
-
440
-
441
-
442
-
443
- def load_dir_0(path,label):
444
-
445
-
446
-
447
- for i in file_0:
448
-
449
- img=cv2.imread(i)
450
-
451
- img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
452
-
453
- img=cv2.resize(img,in_size)
454
-
455
- img=img/255.0
456
-
457
- x.append(img)
458
-
459
- z.append(label)
460
-
461
- return [x,z]
462
376
 
463
377
 
464
378
 

4

必要なライブラリのインポートを行った

2020/07/14 06:36

投稿

koukiten
koukiten

スコア6

test CHANGED
File without changes
test CHANGED
@@ -152,6 +152,18 @@
152
152
 
153
153
  import cv2
154
154
 
155
+ from keras.layers import Convolution2D, BatchNormalization, Activation, MaxPooling2D, Add, Dropout, Flatten, Dense
156
+
157
+ from keras import optimizers
158
+
159
+ from keras.utils import to_categorical
160
+
161
+
162
+
163
+ from keras import models
164
+
165
+ from keras import layers
166
+
155
167
 
156
168
 
157
169
  x=[]
@@ -186,7 +198,7 @@
186
198
 
187
199
  path_eight= path +'/Dataset/eight'
188
200
 
189
- path_nine = path +'/Dataset/ine'
201
+ path_nine = path +'/Dataset/nine'
190
202
 
191
203
  path_zero = path +'/Dataset/zero'
192
204
 
@@ -312,9 +324,9 @@
312
324
 
313
325
  return [x,z]
314
326
 
315
-
316
-
317
-
327
+
328
+
329
+
318
330
 
319
331
  def load_dir_5(path,label):
320
332
 
@@ -336,7 +348,7 @@
336
348
 
337
349
  return [x,z]
338
350
 
339
-
351
+
340
352
 
341
353
  def load_dir_6(path,label):
342
354
 
@@ -402,7 +414,7 @@
402
414
 
403
415
  return [x,z]
404
416
 
405
-
417
+
406
418
 
407
419
  def load_dir_9(path,label):
408
420
 
@@ -424,9 +436,9 @@
424
436
 
425
437
  return [x,z]
426
438
 
427
-
428
-
429
-
439
+
440
+
441
+
430
442
 
431
443
  def load_dir_0(path,label):
432
444
 
@@ -552,6 +564,4 @@
552
564
 
553
565
 
554
566
 
555
-
556
-
557
567
  ```

3

2020/07/14 06:02

投稿

koukiten
koukiten

スコア6

test CHANGED
File without changes
test CHANGED
@@ -490,6 +490,12 @@
490
490
 
491
491
 
492
492
 
493
+ x=np.array(x)
494
+
495
+ z=np.array(z)
496
+
497
+
498
+
493
499
 
494
500
 
495
501
  import keras

2

2020/07/14 05:51

投稿

koukiten
koukiten

スコア6

test CHANGED
File without changes
test CHANGED
@@ -450,43 +450,43 @@
450
450
 
451
451
 
452
452
 
453
- load_dir_1(path_one_speckle,1)
453
+ load_dir_1(path_one,1)
454
-
455
-
456
-
454
+
455
+
456
+
457
- load_dir_2(path_two_speckle,2)
457
+ load_dir_2(path_two,2)
458
-
459
-
460
-
458
+
459
+
460
+
461
- load_dir_3(path_three_speckle,3)
461
+ load_dir_3(path_three,3)
462
-
463
-
464
-
462
+
463
+
464
+
465
- load_dir_4(path_four_speckle,4)
465
+ load_dir_4(path_four,4)
466
-
467
-
468
-
466
+
467
+
468
+
469
- load_dir_5(path_five_speckle,5)
469
+ load_dir_5(path_five,5)
470
-
471
-
472
-
470
+
471
+
472
+
473
- load_dir_6(path_six_speckle,6)
473
+ load_dir_6(path_six,6)
474
-
475
-
476
-
474
+
475
+
476
+
477
- load_dir_7(path_seven_speckle,7)
477
+ load_dir_7(path_seven,7)
478
-
479
-
480
-
478
+
479
+
480
+
481
- load_dir_8(path_eight_speckle,8)
481
+ load_dir_8(path_eight,8)
482
-
483
-
484
-
482
+
483
+
484
+
485
- load_dir_9(path_nine_speckle,9)
485
+ load_dir_9(path_nine,9)
486
-
487
-
488
-
486
+
487
+
488
+
489
- load_dir_0(path_zero_speckle,0)
489
+ load_dir_0(path_zero,0)
490
490
 
491
491
 
492
492
 

1

2020/07/14 05:15

投稿

koukiten
koukiten

スコア6

test CHANGED
File without changes
test CHANGED
@@ -494,13 +494,13 @@
494
494
 
495
495
  import keras
496
496
 
497
- x_train,x_test,y_train,y_test,z_train,z_test,t_train,t_test=train_test_split(x,y,z,t,test_size=0.2)
497
+ x_train,x_test,z_train,z_test=train_test_split(x,z,test_size=0.2)
498
-
499
-
500
-
498
+
499
+
500
+
501
- x_train=x_train.reshape(len(x_train),256,256,1).astype('float32')
501
+ x_train=x_train.reshape(len(x_train),28,28,1).astype('float32')
502
-
502
+
503
- x_test=x_test.reshape(len(x_test),256,256,1).astype('float32')
503
+ x_test=x_test.reshape(len(x_test),28,28,1).astype('float32')
504
504
 
505
505
 
506
506