def getTrainAndValidationData(self, validation_split=7): (X_train, y_train) = readH5FileTrain(self.__h5file__) #so it fits into memory without paging reduce_to = int(X_train.shape[0] * NormalizedSpectrograms.__trainSizeReduction) X_train = X_train[:reduce_to] y_train = y_train[:reduce_to] self.__getMeanAndSd(X_train, y_train) #normalize spectrograms X_train = np.subtract(X_train, self.__mean) X_train = np.divide(X_train, self.__sd) #normalize bpms print(self.__y_mean,self.__y_sd) #shuffle everything learnLib.shuffle_in_unison(X_train, y_train) split_at = X_train.shape[0] // validation_split X_validate = X_train[:split_at] Y_validate = np.array(list(map(self.normalize_bpm, y_train[:split_at]))) Y_train = np.array(list(map(self.normalize_bpm, y_train[split_at:]))) X_train = (X_train[split_at:]) return (X_train, Y_train), (X_validate, Y_validate)
def getTrainData(self, validation_split=7): (X_train, y_train) = readH5FileTrain(self.__h5file__) #so it fits into memory without paging reduce_to = int(X_train.shape[0] * SubjectSplitSpectrograms.__trainSizeReduction) X_train = X_train[:reduce_to] y_train = y_train[:reduce_to] if not self.__subjectIdependant: (X, y) = readH5FileValidate(self.__h5file__) y_train = np.concatenate([y_train, y],0) X_train = np.concatenate([X_train, X],0) X_train = np.array(X_train) y_train = np.array(y_train) print(X_train.shape) rnd = np.random.rand(y_train.shape[0]) X_train = X_train[rnd > 0.8] y_train = y_train[rnd > 0.8] X_train = X_train[y_train < 140] y_train = y_train[y_train < 140] print(X_train.shape) #shuffle everything learnLib.shuffle_in_unison(X_train, y_train) if not self.__subjectIdependant: split_at = X_train.shape[0] // 4 self.X_validate = X_train[:split_at] self.Y_validate = np.array(y_train[:split_at]) y_train = y_train[split_at:] X_train = (X_train[split_at:]) Y_train = np.array(y_train) return X_train, Y_train
def getTrainData(self, validation_split=7): (X_train, y_train) = readH5FileTrain(self.__h5file__) #so it fits into memory without paging reduce_to = int(X_train.shape[0] * SubjectSplitSpectrograms.__trainSizeReduction) X_train = X_train[:reduce_to] y_train = y_train[:reduce_to] if not self.__subjectIdependant: (X, y) = readH5FileValidate(self.__h5file__) y_train = np.concatenate([y_train, y], 0) X_train = np.concatenate([X_train, X], 0) X_train = np.array(X_train) y_train = np.array(y_train) print(X_train.shape) rnd = np.random.rand(y_train.shape[0]) X_train = X_train[rnd > 0.8] y_train = y_train[rnd > 0.8] X_train = X_train[y_train < 140] y_train = y_train[y_train < 140] print(X_train.shape) #shuffle everything learnLib.shuffle_in_unison(X_train, y_train) if not self.__subjectIdependant: split_at = X_train.shape[0] // 4 self.X_validate = X_train[:split_at] self.Y_validate = np.array(y_train[:split_at]) y_train = y_train[split_at:] X_train = (X_train[split_at:]) Y_train = np.array(y_train) return X_train, Y_train