View source on GitHub
|
A preprocessing layer which randomly zooms images during training.
Inherits From: Layer, Operation
tf.keras.layers.RandomZoom(
height_factor,
width_factor=None,
fill_mode='reflect',
interpolation='bilinear',
seed=None,
fill_value=0.0,
data_format=None,
**kwargs
)
Used in the notebooks
| Used in the guide | Used in the tutorials |
|---|---|
This layer will randomly zoom in or out on each axis of an image
independently, filling empty space according to fill_mode.
Input pixel values can be of any range (e.g. [0., 1.) or [0, 255]) and
of integer or floating point dtype.
By default, the layer will output floats.
Input shape | |
|---|---|
3D
|
unbatched) or 4D (batched) tensor with shape
|
Output shape | |
|---|---|
3D
|
unbatched) or 4D (batched) tensor with shape
|
Example:
input_img = np.random.random((32, 224, 224, 3))layer = keras.layers.RandomZoom(.5, .2)out_img = layer(input_img)
Methods
convert_weight
convert_weight(
weight
)
Convert the weight if it is from the a different backend.
from_config
@classmethodfrom_config( config )
Creates an operation from its config.
This method is the reverse of get_config, capable of instantiating the
same operation from the config dictionary.
if "dtype" in config and isinstance(config["dtype"], dict):
policy = dtype_policies.deserialize(config["dtype"])
| Args | |
|---|---|
config
|
A Python dictionary, typically the output of get_config.
|
| Returns | |
|---|---|
| An operation instance. |
get_clipped_bbox
get_clipped_bbox(
bounding_boxes, h_end, h_start, w_end, w_start
)
get_random_transformation
get_random_transformation(
data, training=True, seed=None
)
get_transformed_x_y
get_transformed_x_y(
x, y, transform
)
transform_bounding_boxes
transform_bounding_boxes(
bounding_boxes, transformation, training=True
)
transform_images
transform_images(
images, transformation, training=True
)
transform_labels
transform_labels(
labels, transformation, training=True
)
transform_segmentation_masks
transform_segmentation_masks(
segmentation_masks, transformation, training=True
)
transform_single_bounding_box
transform_single_bounding_box(
bounding_box, transformation, training=True
)
transform_single_image
transform_single_image(
image, transformation, training=True
)
transform_single_label
transform_single_label(
label, transformation, training=True
)
transform_single_segmentation_mask
transform_single_segmentation_mask(
segmentation_mask, transformation, training=True
)
View source on GitHub