Spec-Zone.ru › TensorFlow

tf.image.extract_glimpse

Извлекает фрагмент из входного тензора.

tf.image.extract_glimpse(
    input,
    size,
    offsets,
    centered=True,
    normalized=True,
    noise='uniform',
    name=None
)

Возвращает набор окон, называемых фрагментами, извлеченными в позиции offsets из входного тензора. Если окна частично перекрывают входные данные, то неперекрытые области будут заполнены случайным шумом.

Результат — 4-мерный тензор формы [batch_size, glimpse_height, glimpse_width, channels]. Размерности каналов и батчей совпадают с входным тензором. Высота и ширина выходных окон задаются в параметре size.

Аргументы normalized и centered управляют тем, как строятся окна:

  • Если координаты нормализованы, но не центрированы, 0,0 и 1,0 соответствуют минимальному и максимальному значениям каждой размерности высоты и ширины.
  • Если координаты нормализованы и центрированы, они находятся в диапазоне от -1,0 до 1,0. Координаты (-1,0, -1,0) соответствуют верхнему левому углу, нижний правый угол находится в (1,0, 1,0), а центр — в (0, 0).
  • Если координаты не нормализованы, они интерпретируются как числа пикселей.

Пример использования:

x = [[[[0.0],
          [1.0],
          [2.0]],
         [[3.0],
          [4.0],
          [5.0]],
         [[6.0],
          [7.0],
          [8.0]]]]
tf.image.extract_glimpse(x, size=(2, 2), offsets=[[1, 1]],
                        centered=False, normalized=False)
<tf.Tensor: shape=(1, 2, 2, 1), dtype=float32, numpy=
array([[[[4.],
         [5.]],
        [[7.],
         [8.]]]], dtype=float32)>
Аргументы
input A Tensor of type float32. A 4-D float tensor of shape [batch_size, height, width, channels].
size A Tensor of type int32. A 1-D tensor of 2 elements containing the size of the glimpses to extract. The glimpse height must be specified first, following by the glimpse width.
offsets A Tensor of type float32. A 2-D integer tensor of shape [batch_size, 2] containing the y, x locations of the center of each window.
centered An optional bool. Defaults to True. indicates if the offset coordinates are centered relative to the image, in which case the (0, 0) offset is relative to the center of the input images. If false, the (0,0) offset corresponds to the upper left corner of the input images.
normalized An optional bool. Defaults to True. indicates if the offset coordinates are normalized.
noise An optional string. Defaults to uniform. indicates if the noise should be uniform (uniform distribution), gaussian (gaussian distribution), or zero (zero padding).
name A name for the operation (optional).
Возвращаемые значения
A Tensor of type float32.

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/image/extract_glimpse

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API