def random_transform(self, x, seed=None):
    'Randomly augments a single image tensor.\n\n        # Arguments\n            x: 3D tensor, single image.\n            seed: Random seed.\n\n        # Returns\n            A randomly transformed version of the input (same shape).\n        '
    img_row_axis = (self.row_axis - 1)
    img_col_axis = (self.col_axis - 1)
    img_channel_axis = (self.channel_axis - 1)
    if (seed is not None):
        np.random.seed(seed)
    if self.rotation_range:
        theta = np.deg2rad(np.random.uniform((- self.rotation_range), self.rotation_range))
    else:
        theta = 0
    if self.height_shift_range:
        try:
            tx = np.random.choice(self.height_shift_range)
            tx *= np.random.choice([(- 1), 1])
        except ValueError:
            tx = np.random.uniform((- self.height_shift_range), self.height_shift_range)
        if (np.max(self.height_shift_range) < 1):
            tx *= x.shape[img_row_axis]
    else:
        tx = 0
    if self.width_shift_range:
        try:
            ty = np.random.choice(self.width_shift_range)
            ty *= np.random.choice([(- 1), 1])
        except ValueError:
            ty = np.random.uniform((- self.width_shift_range), self.width_shift_range)
        if (np.max(self.width_shift_range) < 1):
            ty *= x.shape[img_col_axis]
    else:
        ty = 0
    if self.shear_range:
        shear = np.deg2rad(np.random.uniform((- self.shear_range), self.shear_range))
    else:
        shear = 0
    if ((self.zoom_range[0] == 1) and (self.zoom_range[1] == 1)):
        (zx, zy) = (1, 1)
    else:
        (zx, zy) = np.random.uniform(self.zoom_range[0], self.zoom_range[1], 2)
    transform_matrix = None
    if (theta != 0):
        rotation_matrix = np.array([[np.cos(theta), (- np.sin(theta)), 0], [np.sin(theta), np.cos(theta), 0], [0, 0, 1]])
        transform_matrix = rotation_matrix
    if ((tx != 0) or (ty != 0)):
        shift_matrix = np.array([[1, 0, tx], [0, 1, ty], [0, 0, 1]])
        transform_matrix = (shift_matrix if (transform_matrix is None) else np.dot(transform_matrix, shift_matrix))
    if (shear != 0):
        shear_matrix = np.array([[1, (- np.sin(shear)), 0], [0, np.cos(shear), 0], [0, 0, 1]])
        transform_matrix = (shear_matrix if (transform_matrix is None) else np.dot(transform_matrix, shear_matrix))
    if ((zx != 1) or (zy != 1)):
        zoom_matrix = np.array([[zx, 0, 0], [0, zy, 0], [0, 0, 1]])
        transform_matrix = (zoom_matrix if (transform_matrix is None) else np.dot(transform_matrix, zoom_matrix))
    if (transform_matrix is not None):
        (h, w) = (x.shape[img_row_axis], x.shape[img_col_axis])
        transform_matrix = transform_matrix_offset_center(transform_matrix, h, w)
        x = apply_transform(x, transform_matrix, img_channel_axis, fill_mode=self.fill_mode, cval=self.cval)
    if (self.channel_shift_range != 0):
        x = random_channel_shift(x, self.channel_shift_range, img_channel_axis)
    if self.horizontal_flip:
        if (np.random.random() < 0.5):
            x = flip_axis(x, img_col_axis)
    if self.vertical_flip:
        if (np.random.random() < 0.5):
            x = flip_axis(x, img_row_axis)
    if (self.brightness_range is not None):
        x = random_brightness(x, self.brightness_range)
    return x
Randomly augments a single image tensor.

# Arguments
    x: 3D tensor, single image.
    seed: Random seed.

# Returns
    A randomly transformed version of the input (same shape).
def random_transform(self, x, seed=None):
    'Randomly augments a single image tensor.\n\n        # Arguments\n            x: 3D tensor, single image.\n            seed: Random seed.\n\n        # Returns\n            A randomly transformed version of the input (same shape).\n        '
    img_row_axis = (self.row_axis - 1)
    img_col_axis = (self.col_axis - 1)
    img_channel_axis = (self.channel_axis - 1)
    if (seed is not None):
        np.random.seed(seed)
    if self.rotation_range:
        theta = np.deg2rad(np.random.uniform((- self.rotation_range), self.rotation_range))
    else:
        theta = 0
    if self.height_shift_range:
        try:
            tx = np.random.choice(self.height_shift_range)
            tx *= np.random.choice([(- 1), 1])
        except ValueError:
            tx = np.random.uniform((- self.height_shift_range), self.height_shift_range)
        if (np.max(self.height_shift_range) < 1):
            tx *= x.shape[img_row_axis]
    else:
        tx = 0
    if self.width_shift_range:
        try:
            ty = np.random.choice(self.width_shift_range)
            ty *= np.random.choice([(- 1), 1])
        except ValueError:
            ty = np.random.uniform((- self.width_shift_range), self.width_shift_range)
        if (np.max(self.width_shift_range) < 1):
            ty *= x.shape[img_col_axis]
    else:
        ty = 0
    if self.shear_range:
        shear = np.deg2rad(np.random.uniform((- self.shear_range), self.shear_range))
    else:
        shear = 0
    if ((self.zoom_range[0] == 1) and (self.zoom_range[1] == 1)):
        (zx, zy) = (1, 1)
    else:
        (zx, zy) = np.random.uniform(self.zoom_range[0], self.zoom_range[1], 2)
    transform_matrix = None
    if (theta != 0):
        rotation_matrix = np.array([[np.cos(theta), (- np.sin(theta)), 0], [np.sin(theta), np.cos(theta), 0], [0, 0, 1]])
        transform_matrix = rotation_matrix
    if ((tx != 0) or (ty != 0)):
        shift_matrix = np.array([[1, 0, tx], [0, 1, ty], [0, 0, 1]])
        transform_matrix = (shift_matrix if (transform_matrix is None) else np.dot(transform_matrix, shift_matrix))
    if (shear != 0):
        shear_matrix = np.array([[1, (- np.sin(shear)), 0], [0, np.cos(shear), 0], [0, 0, 1]])
        transform_matrix = (shear_matrix if (transform_matrix is None) else np.dot(transform_matrix, shear_matrix))
    if ((zx != 1) or (zy != 1)):
        zoom_matrix = np.array([[zx, 0, 0], [0, zy, 0], [0, 0, 1]])
        transform_matrix = (zoom_matrix if (transform_matrix is None) else np.dot(transform_matrix, zoom_matrix))
    if (transform_matrix is not None):
        (h, w) = (x.shape[img_row_axis], x.shape[img_col_axis])
        transform_matrix = transform_matrix_offset_center(transform_matrix, h, w)
        x = apply_transform(x, transform_matrix, img_channel_axis, fill_mode=self.fill_mode, cval=self.cval)
    if (self.channel_shift_range != 0):
        x = random_channel_shift(x, self.channel_shift_range, img_channel_axis)
    if self.horizontal_flip:
        if (np.random.random() < 0.5):
            x = flip_axis(x, img_col_axis)
    if self.vertical_flip:
        if (np.random.random() < 0.5):
            x = flip_axis(x, img_row_axis)
    if (self.brightness_range is not None):
        x = random_brightness(x, self.brightness_range)
    return x