Skip to content

code segment about scale #137

@HeConnor

Description

@HeConnor

Hi,

I have a question about the "scale"; the following code segment:

if do_scale and np.random.uniform() < p_scale_per_sample:
   if independent_scale_for_each_axis and np.random.uniform() < p_independent_scale_per_axis:
       sc = []
       for _ in range(dim):
           if np.random.random() < 0.5 and scale[0] < 1:
               sc.append(np.random.uniform(scale[0], 1))      #
           else:
               sc.append(np.random.uniform(max(scale[0], 1), scale[1]))
   else:
       if np.random.random() < 0.5 and scale[0] < 1:
           sc = np.random.uniform(scale[0], 1)
       else:
           sc = np.random.uniform(max(scale[0], 1), scale[1])

I'm confused and has this design considered other issues?

I think should the code be changed to this:

...
       for _ in range(dim):
           if np.random.random() < 0.5 and scale[0] < 1:
               sc.append(np.random.uniform(scale[0], min(scale[1], 1)))
           else:
               sc.append(np.random.uniform(max(scale[0], 1), scale[1]))
   else:
       if np.random.random() < 0.5 and scale[0] < 1:
           sc = np.random.uniform(scale[0], min(scale[1], 1))
       else:
           sc = np.random.uniform(max(scale[0], 1), scale[1])

Or more simplified:

if independent_scale_for_each_axis and np.random.uniform() < p_independent_scale_per_axis:
    sc = []
    for _ in range(dim):
        sc.append(np.random.uniform(scale[0], scale[1]))
else:
    sc = np.random.uniform(scale[0], scale[1])

Best regards,
Connor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions