Exemplo n.º 1
0
 def f(dat):
     ds = []
     for row in dat:
         s, a = self.forge(row)
         ds.append((s, a))
     ds = np.array(ds)
     return DataSet(np.vstack(ds[:, 0]).reshape((-1, h, w, c)), np.vstack(ds[:, 1]))
Exemplo n.º 2
0
    def adapt(self, filename):
        ds = []
        dat = self.load_dataset(filename)
        for row in dat:
            s, a = self.forge(row)
            ds.append((s, a))

        ds = np.array(ds)

        np.random.shuffle(ds)

        size = ds.shape[0]
        train_size = int(size * 0.8)
        train = ds[:train_size, :]
        test = ds[train_size:, :]

        validation_size = int(train.shape[0] * 0.2)
        validation = train[:validation_size, :]
        train = train[validation_size:, :]

        h, w, c = self.get_input_shape()
        train = DataSet(
            np.vstack(train[:, 0]).reshape((-1, h, w, c)),
            np.vstack(train[:, 1]))
        validation = DataSet(
            np.vstack(validation[:, 0]).reshape((-1, h, w, c)),
            np.vstack(validation[:, 1]))
        test = DataSet(
            np.vstack(test[:, 0]).reshape((-1, h, w, c)), np.vstack(test[:,
                                                                         1]))

        print(train.images.shape, train.labels.shape)
        print(validation.images.shape, validation.labels.shape)
        print(test.images.shape, test.labels.shape)

        self.ds_train = train
        self.ds_valid = validation
        self.ds_test = test