udacity / dlnd-issue-reports

5 stars 0 forks source link

DCGAN Dataset Class #535

Closed rahul-ahuja closed 6 years ago

rahul-ahuja commented 6 years ago

In DCGAN notebook, it will be better coding practice to have self.train_x instead of dataset.train_x for Class Dataset;

class Dataset:
    def __init__(self, train, test, val_frac=0.5, shuffle=False, scale_func=None):
        split_idx = int(len(test['y'])*(1 - val_frac))
        self.test_x, self.valid_x = test['X'][:,:,:,:split_idx], test['X'][:,:,:,split_idx:]
        self.test_y, self.valid_y = test['y'][:split_idx], test['y'][split_idx:]
        self.train_x, self.train_y = train['X'], train['y']
.....
.....
.....
    def batches(self, batch_size):
        if self.shuffle:
----->            idx = np.arange(len(dataset.train_x))
            np.random.shuffle(idx)
            self.train_x = self.train_x[idx]
            self.train_y = self.train_y[idx]
.....
.....

            yield self.scaler(x), y
lcrucks commented 6 years ago

Fixed