我一直在玩CNN试图从相对较大的图像中去除相干噪声 . 由于图像很大,我不能一次加载到内存中太多 . Size of images: 1500x250 . 由于这个问题,我试图实现一个将图像输送到网络的生成器 . 我一直在努力获得不好的结果,但是假设网络中存在问题 . 我尝试将fit()与我的数据子集一起使用,并且在不对网络做任何事情的情况下获得了非常好的结果 . 在同一子集上测试生成器会导致错误的结果 . 有什么东西我看不到?为什么我的发电机失灵了?

我的数据集大约是114 000张图像,大约是475 GB,因此解释了为什么我不能一次将所有内容加载到内存中 . 我得到了结果,它们是重现图像的实际结果,但它们非常糟糕 . 我的发电机班我在这里:

class genOne(k.utils.Sequence):
        def __init__(self, img_rows, img_cols, channels, batch_size, clean_dir,
                noisy_dir, clean_files, noisy_files, shuffle=True):
            """Initialize variables:
            img_rows, img_cols, channels: the shape of the image
            batch_size                  : Self explanatory
            clean_dir, noisy_dir        : directories with files
            clean_files                 : Randomized list with clean images
            noisy_file                  : Randomized list with noise"""
            self.img_rows = img_rows
            self.img_cols = img_cols
            self.channels = channels
            self.batch_size = batch_size
            self.clean_dir = clean_dir
            self.noisy_dir = noisy_dir
            self.clean_files = clean_files.tolist()
            self.noisy_files = noisy_files.tolist()
            self.shuffled_noisy = []
            self.tmp_noisy = []
            self.tmp_clean = []
            self.shuffle = shuffle
            self.on_epoch_end()


        def __len__(self):
            """Sets the number of batches per epoch"""
            return floor((len(self.noisy_files)*len(self.clean_files))/self.batch_size)


        def __getitem__(self, index):
            """Generates data for each batch
               combine every type of noise with each image."""
            X = np.empty((self.batch_size, self.img_rows, self.img_cols,
                                                        self.channels))
            Y = np.zeros((self.batch_size, self.img_rows, self.img_cols,
                                                        self.channels))
            for i in range(self.batch_size):
                if not self.tmp_noisy:
                    self.tmp_noisy = self.shuffled_noisy
                    self.tmp_clean.pop(0)
                x_test = self.tmp_noisy.pop(0)
                X[i,] = np.expand_dims(np.load(self.noisy_dir + x_test).T[
                                  :self.img_rows,:self.img_cols],-1)
                Y[i,] = np.expand_dims(np.load(self.clean_dir + self.tmp_clean[0
                            ]).T[:self.img_rows, :self.img_cols],-1)
                y_test = self.tmp_clean[0]
                # Input equals ground truth + noise
                X[i,] += Y[i,]
                # Normalize data between 0 and 1
                X[i,] = ((X[i,]/np.amax(np.absolute(X[i,])))+1)/2
                Y[i,] = ((Y[i,]/np.amax(np.absolute(Y[i,])))+1)/2
            return X, Y


        def on_epoch_end(self):
            """Refresh all data on epoch end"""
            self.tmp_noisy = self.noisy_files
            self.tmp_clean = self.clean_files
            if self.shuffle == True:
                np.random.shuffle(self.tmp_noisy)
                np.random.shuffle(self.tmp_clean)
            self.shuffled_noisy = self.tmp_noisy

我有475个干净的图像,300个图像由纯噪声组成 . 我将它们组合在一起,使每个图像都以各种类型的噪声馈入网络 . 使用fit()工作的小盒子只是300张图像,其中每张图像都是不同的干净图像,具有不同的噪点 .

我知道我的驱动程序版本相当陈旧,需要旧版本的tensorflow . 我不能更新这个,所以我坚持使用tensorflow 1.4.1 .

Specs:

  • 2x Nvidia Geforce GTX 1080 7.9 GB

  • Nvidia驱动程序版本367.44

  • cuDNN 6.0.21

  • CUDA 8.0

  • Debian Wheezy 7

  • Tensorflow-gpu 1.4.1

  • Keras 2.0.8

  • Python 3.6.7