質問編集履歴
2
ソースコードの詳細
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -13,11 +13,53 @@ | |
| 13 13 |  | 
| 14 14 | 
             
            ### 該当のソースコード
         | 
| 15 15 |  | 
| 16 | 
            +
            import numpy as np
         | 
| 16 | 
            -
             | 
| 17 | 
            +
            import matplotlib.pyplot as plt
         | 
| 17 | 
            -
            (x_train, y_train),(x_test, y_test) = mnist.load_data()
         | 
| 18 18 |  | 
| 19 | 
            -
             | 
| 19 | 
            +
            from tensorflow.python import keras
         | 
| 20 | 
            +
            from tensorflow.python.keras import backend as K
         | 
| 21 | 
            +
            from tensorflow.python.keras.models import Model, Sequential
         | 
| 22 | 
            +
            from tensorflow.python.keras.layers import Conv2D, Dense, Input, MaxPooling2D, UpSampling2D, Lambda
         | 
| 23 | 
            +
            from tensorflow.python.keras.preprocessing.image import load_img, img_to_array, array_to_img, ImageDataGenerator
         | 
| 20 24 |  | 
| 25 | 
            +
             | 
| 26 | 
            +
            ls drive/My\ Drive/poke64
         | 
| 27 | 
            +
            (x_train, y_train),(x_test, y_test) =?????????????????????????
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            /////////CNNで扱いやすい形に変形
         | 
| 30 | 
            +
            x_train = x_train.reshape(-1,28,28,1)
         | 
| 31 | 
            +
            x_test = x_test.reshape(-1,28,28,1)
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            ////////特徴量の正規化
         | 
| 34 | 
            +
            x_train = x_train/255.
         | 
| 35 | 
            +
            x_test = x_test/255.
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            /////////////マスキングノイズ
         | 
| 38 | 
            +
            def make_masking_noise_data(data_x,percent=0.1):
         | 
| 39 | 
            +
              size = data_x.shape
         | 
| 40 | 
            +
              masking = np.random.binomial(n=1, p=percent,size=size)
         | 
| 41 | 
            +
              return data_x*masking
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            x_train_masked = make_masking_noise_data(x_train)
         | 
| 44 | 
            +
            x_test_masked = make_masking_noise_data(x_test)
         | 
| 45 | 
            +
             | 
| 46 | 
            +
             | 
| 47 | 
            +
            /////////////ガウシアンノイズ
         | 
| 48 | 
            +
            def make_gaussian_noise_data(data_x, scale=0.8):
         | 
| 49 | 
            +
              gaussian_data_x = data_x + np.random.normal(loc=0, scale=scale, size=data_x.shape)
         | 
| 50 | 
            +
              gaussian_data_x = np.clip(gaussian_data_x, 0, 1)
         | 
| 51 | 
            +
              return gaussian_data_x
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            x_train_gauss = make_gaussian_noise_data(x_train)
         | 
| 54 | 
            +
            x_test_gauss = make_gaussian_noise_data(x_test)
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            /////////ノイズをかけた画像の表示
         | 
| 57 | 
            +
            from IPython.display import display_png
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            display_png(array_to_img(x_train[0]))
         | 
| 60 | 
            +
            display_png(array_to_img(x_train_gauss[0]))
         | 
| 61 | 
            +
            display_png(array_to_img(x_train_masked[0]))
         | 
| 62 | 
            +
             | 
| 21 63 | 
             
            ### 試したこと
         | 
| 22 64 |  | 
| 23 65 |  | 
1
誤字
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -13,7 +13,10 @@ | |
| 13 13 |  | 
| 14 14 | 
             
            ### 該当のソースコード
         | 
| 15 15 |  | 
| 16 | 
            +
            from tensorflow.python.keras.datasets import mnist
         | 
| 17 | 
            +
            (x_train, y_train),(x_test, y_test) = mnist.load_data()
         | 
| 16 18 |  | 
| 19 | 
            +
            これの自分で用意したデータ版のやり方
         | 
| 17 20 |  | 
| 18 21 | 
             
            ### 試したこと
         | 
| 19 22 |  | 
