I am working on a regression problem and try to implement data augmentation for it.
My xs are slices of N continuous rows of tabular data that I want to randomly select from 2N rows. My targets (ys) are numbers depending on the starting point of my xs. (e.g. if my x starts at row m, I have to select the corresponding y from row m.)
So, what I need is a transform that uses the same random number m for xs and ys but does different things for x and y.
I tried to understand how it is done in vision where tfm and tfm_y share e.g. the same rotation angle, but I have no clue how it is done.
If you want to use the same API as the transforms in vision, you will need to pass a type annotation to your parameter that can be randomized (see the transforms like rotate). Then the actual transform will tfm = RandTransform(your_function).
A value is selected for them when you apply tfm.resolve().
Then you will need to define apply_tfms for the items you are using, in which you will need to have an argument named do_resolve (it will be True by default, and the pipeline sends it to False when you apply the transform to the target). If it’s True start by doing tfm.resolve() for each of the tfm passed (this function takes a list of transforms) before applying them to your item (probably for tfm in tfms: self = tfm(self)).
Is there any chance you could give more of a code based example?
In my case I want to apply a different transform to a Y image. Essentially training depth detection from an image. When I zoom, for the image it’s the normal way, however for the depth image it’s both the normal zoom plus the modification of the pixel values.