View source on GitHub
|
A preprocessing layer which resizes images.
Inherits From: Layer, Operation
tf.keras.layers.Resizing(
height,
width,
interpolation='bilinear',
crop_to_aspect_ratio=False,
pad_to_aspect_ratio=False,
fill_mode='constant',
fill_value=0.0,
antialias=False,
data_format=None,
**kwargs
)
Used in the notebooks
| Used in the tutorials |
|---|
This layer resizes an image input to a target height and width. The input
should be a 4D (batched) or 3D (unbatched) tensor in "channels_last"
format. Input pixel values can be of any range
(e.g. [0., 1.) or [0, 255]).
Input shape | |
|---|---|
3D
|
unbatched) or 4D (batched) tensor with shape
|
Output shape | |
|---|---|
3D
|
unbatched) or 4D (batched) tensor with shape
|
Example:
(x_train, y_train), _ = keras.datasets.cifar10.load_data()
image = x_train[0]
resizer = keras.layers.Resizing(128, 128)
resized_image = resizer(image)
print("original:", image.shape, "resized:", resized_image.shape)
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_random_transformation
get_random_transformation(
data, training=True, seed=None
)
transform_bounding_boxes
transform_bounding_boxes(
bounding_boxes, transformation, training=True
)
transform_images
transform_images(
images, transformation=None, training=True
)
transform_labels
transform_labels(
labels, transformation=None, training=True
)
transform_segmentation_masks
transform_segmentation_masks(
segmentation_masks, transformation=None, 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