Skip to content

Sample Code of preprocessing() method in DatasetClass #8

Description

@getty708

Here is a sample code to implement the preprocessing() method.
preprocessing() is called after the input data is loaded by load_dataset() method.

Loaded timeseries are stored in self.data property as dict, and you can get acceleration data by self.data[i].get("data").
You can implement preprocessing such as normalization or standardization by updating the data property within this method.

class OpenPackImu(optorch.data.datasets.OpenPackImu):

    def preprocessing(self) -> None:
        """
        * Normalize [-3G, +3G] into [0, 1].
        """
        # NOTE: Normalize ACC data. ([-3G, +3G] -> [0, 1])
        for seq_dict in self.data:
            x = seq_dict.get("data")
            x = np.clip(x, -3, +3)
            x = (x + 3.) / 6.
            seq_dict["data"] = x

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions