Augmentations¶
‘astronet’ contains many built-in data augmentation methods. Each of these methods are contained in their own class, only containing their own parameters and an ‘apply’ method. The augmentations are shown below. To implement your own method, simply extend the Identity method and override the ‘apply’ method to apply the augmentation that you want.
Standard augmentations¶
Cropping¶
-
class
astronet.augmentations.Crop(x_range=(0, None), y_range=(0, None), verbose=0)¶ Crop an input to the selected range of values.
Parameters: x_range : tuple or list, default (0,-1)
Contains beginning and endpoints of the slice in the x direction.
y_range : tuple or list, default (0,-1)
Contains beginning and endpoints of the slice in the y direction.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: X : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
-
class
astronet.augmentations.RandomCrop(x_len=0, y_len=0, verbose=0)¶ Crop an input to the selected range of values.
Parameters: x_len : integer, default 0
Width of the cropped input, no cropping when set to 0.
y_len : integer, default 0
Height of the cropped input, no cropping when set to 0.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
Flipping¶
-
class
astronet.augmentations.FlipUD(selected_classes=None, prob=0.5, verbose=0)¶ Vertically mirrors each input pattern with a given probability.
Parameters: selected_classes : list or None, default None
Labels of classes to which this augmentation should be applied. Should be None for regression.
prob : float, default 0.5
A value between 0 and 1, which sets the probability with which an image is selected to be augmented.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
-
class
astronet.augmentations.FlipLR(selected_classes=None, prob=0.5, verbose=0)¶ Horizontally mirrors each input pattern with a given probability.
Parameters: selected_classes : list or None, default None
Labels of classes to which this augmentation should be applied. Should be None for regression.
prob : float, default 0.5
A value between 0 and 1, which sets the probability with which an image is selected to be augmented.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
Noise¶
-
class
astronet.augmentations.AddNoise(scale=10, distribution='gaussian', verbose=0)¶ Add randomly generated noise from a given distribution to each input.
Parameters: scale : list or int, default 10
Value for the highest possible noise. If a list, this highest value will be randomly selected from the provided range.
distribution : string, default ‘gaussian’
Type of distribution the noise should have. Supported values: ‘gaussian’, ‘uniform’.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
-
class
astronet.augmentations.AddConstant(values=[-50, 50], verbose=0)¶ Either adds a constant value to every image, or a randomly selected value for each image.
Parameters: range : int or list, default 10
Adds the same constant to all inputs if input is an integer, otherwise adds a randomly selected constant from the given range.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
Normalization¶
-
class
astronet.augmentations.Normalize(verbose=0)¶ Calculates the batch mean and standard deviation. Then normalizes inputs by first subtracting the mean, then dividing by the standard deviation. This prevents rounding errors when dealing with large inputs and allows for easier learning of the network.
Parameters: verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
Rotation¶
-
class
astronet.augmentations.Rotate(selected_classes=None, rotations=[0, 90, 180, 270], verbose=0)¶ Rotate each input with a randomly selected angle.
Parameters: selected_classes : list or None, default None
Labels of classes to which this augmentation should be applied. Should be None for regression.
rotations : list, default [0,90,180,270]
Values of the angles that the algorithm can choose from.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
Selection¶
-
class
astronet.augmentations.SelectDimensions(dimensions=None, verbose=0)¶ Select certain dimensions from the input (e.g. only R channel from an RGB image, or only u and i filters from a stack of images in ugriz-bands.)
Parameters: dimensions : list or None, default None
Indices of the dimensions that should be kept.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: X : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
Shifting¶
-
class
astronet.augmentations.Shift(selected_classes=None, x_range=[-2, 0, 2], y_range=[-2, 0, 2], mode='constant', cval=0, verbose=0)¶ Shift each image with a randomly selected number of pixels, both horizontally and vertically. Empty pixels can be filled with a constant value or filled in another way. (See ‘scipy.ndimage.interpolation.shift’ documentation.)
Parameters: selected_classes : list or None, default None
Labels of classes to which this augmentation should be applied. Should be None for regression.
x_range : list, default [-2,0,2]
Possible number of pixels to shift the image in x direction.
y_range : list, default [-2,0,2]
Possible number of pixels to shift the image in y direction.
mode : string, default ‘constant’
Mode of interpolation used for empty pixels. Possible values are ‘constant’, ‘nearest’, ‘reflect’, ‘wrap’. The function used is scipy.ndimage.interpolate.shift().
cval : float, default 0.0
Constant value to use for all empty pixels. Only used when ‘mode’ is set to ‘constant’.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
Zooming¶
-
class
astronet.augmentations.ZoomIn(selected_classes=None, factors=[1, 1.1], verbose=0)¶ Zoom in each image with a randomly selected factor.
Parameters: selected_classes : list or None, default None
Labels of classes to which this augmentation should be applied. Should be None for regression.
factors : int, default [1, 1.0]
Possible factors with which zooming is done.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
Astronomical augmentations¶
CCD Errors¶
-
class
astronet.augmentations.EdgeError(selected_classes=None, prob=0.5, verbose=0)¶ Sets a random edge to values smaller than 1 with a given probability.
Parameters: selected_classes : list or None, default None
Labels of classes to which this augmentation should be applied. Should be None for regression.
prob : float, default 0.5
A value between 0 and 1, which sets the probability with which an image is selected to be augmented.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
-
class
astronet.augmentations.DeadColumn(selected_classes=None, prob=0.5, verbose=0)¶ With a given probability, set all values in a randomly selected column to zero.
Parameters: selected_classes : list or None, default None
Labels of classes to which this augmentation should be applied. Should be None for regression.
prob : float, default 0.5
A value between 0 and 1, which sets the probability with which an image is selected to be augmented.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-
Adding foreground stars¶
-
class
astronet.augmentations.AddStar(selected_classes=None, prob=0.5, L_range=[0, 100], var_range=[1, 3], verbose=0)¶ With a given probability, add a foreground star to the input image.
Parameters: selected_classes : list or None, default None
Labels of classes to which this augmentation should be applied. Should be None for regression.
prob : float, default 0.5
Probability that a foreground star is added. Value between 0 and 1.
L_range : list, default [0,100]
Range of values from which the brightness of the added star is selected.
var_range : list, default [1,3]
Range of values from which the width of the added star is selected.
verbose : int, default 0
Verbosity level.
Methods
-
apply(X, Y, features)¶ Apply the augmentation corresponding to this class to the input data.
Parameters: X : array-like
Array of input patterns.
Y : array-like
Array of input labels.
features : array-like
Array of extra input features.
Returns: Xtransformed : array-like (same as X)
Array of transformed input patterns.
Y : array-like (same as Y)
Array of transformed input labels.
features : array–like (same as features)
Array of transformed extra input features.
-