def __getitem__(self, index: int): if self.shuffle: self.randomize(self.data) data1 = self.data[index] data2 = self.data[index+self.__len__()] if self.transform is not None: data1 = apply_transform(self.transform, data1) data2 = apply_transform(self.transform, data2) return (data1, data2)
def __call__(self, data): if len(self.transforms) == 0: return data index = self.R.multinomial(1, self.weights).argmax() _transform = self.transforms[index] data = apply_transform(_transform, data, self.map_items, self.unpack_items, self.log_stats) # if the data is a mapping (dictionary), append the OneOf transform to the end if isinstance(data, Mapping): for key in data.keys(): if self.trace_key(key) in data: self.push_transform(data, key, extra_info={"index": index}) return data
def inverse(self, data): invertible_transforms = [ t for t in self.flatten().transforms if isinstance(t, InvertibleTransform) ] if len(invertible_transforms) == 0: warnings.warn( "inverse has been called but no invertible transforms have been supplied" ) # loop backwards over transforms for t in reversed(invertible_transforms): data = apply_transform(t.inverse, data) return data
def inverse(self, data): invertible_transforms = [ t for t in self.flatten().transforms if isinstance(t, InvertibleTransform) ] if not invertible_transforms: warnings.warn( "inverse has been called but no invertible transforms have been supplied" ) # loop backwards over transforms for t in reversed(invertible_transforms): data = apply_transform(t.inverse, data, self.map_items, self.unpack_items, self.log_stats) return data
def __call__(self, input_): for _transform in self.transforms: input_ = apply_transform(_transform, input_, self.map_items, self.unpack_items, self.log_stats) return input_
def __call__(self, input_): for _transform in self.transforms: input_ = apply_transform(_transform, input_) return input_