從輸入張量中提取一瞥。
用法
tf.compat.v1.image.extract_glimpse(
input, size, offsets, centered=True, normalized=True, uniform_noise=True,
name=None
)
參數
-
input
Tensor
類型為float32
。形狀為[batch_size, height, width, channels]
的 4-D 浮點張量。 -
size
Tensor
類型為int32
。一個 2 個元素的 1-D 張量,包含要提取的 glimpses 的大小。必須首先指定一瞥高度,然後是一瞥寬度。 -
offsets
Tensor
類型為float32
。形狀為[batch_size, 2]
的二維整數張量,包含每個窗口中心的 y、x 位置。 -
centered
可選的bool
。默認為True
。指示偏移坐標是否相對於圖像居中,在這種情況下, (0, 0) 偏移相對於輸入圖像的中心。如果為 false,則 (0,0) 偏移量對應於輸入圖像的左上角。 -
normalized
可選的bool
。默認為True
。指示偏移坐標是否已歸一化。 -
uniform_noise
可選的bool
。默認為True
。指示是否應使用均勻分布或高斯分布生成噪聲。 -
name
操作的名稱(可選)。
返回
-
Tensor
類型為float32
。
從輸入張量返回在位置 offsets
處提取的一組稱為 glimpses 的窗口。如果窗口僅與輸入部分重疊,則非重疊區域將充滿隨機噪聲。
結果是形狀為 [batch_size, glimpse_height,
glimpse_width, channels]
的 4-D 張量。通道和批次維度與輸入張量相同。輸出窗口的高度和寬度在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.compat.v1.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([[[[0.],
[1.]],
[[3.],
[4.]]]], dtype=float32)>
相關用法
- Python tf.compat.v1.image.draw_bounding_boxes用法及代碼示例
- Python tf.compat.v1.image.sample_distorted_bounding_box用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.cross_entropy用法及代碼示例
- Python tf.compat.v1.Variable.eval用法及代碼示例
- Python tf.compat.v1.train.FtrlOptimizer.compute_gradients用法及代碼示例
- Python tf.compat.v1.layers.conv3d用法及代碼示例
- Python tf.compat.v1.strings.length用法及代碼示例
- Python tf.compat.v1.data.Dataset.snapshot用法及代碼示例
- Python tf.compat.v1.data.experimental.SqlDataset.reduce用法及代碼示例
- Python tf.compat.v1.feature_column.categorical_column_with_vocabulary_file用法及代碼示例
- Python tf.compat.v1.data.TextLineDataset.from_tensors用法及代碼示例
- Python tf.compat.v1.variable_scope用法及代碼示例
- Python tf.compat.v1.data.experimental.SqlDataset.as_numpy_iterator用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.covariance用法及代碼示例
- Python tf.compat.v1.placeholder用法及代碼示例
- Python tf.compat.v1.layers.Conv3D用法及代碼示例
- Python tf.compat.v1.train.get_or_create_global_step用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.image.extract_glimpse。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。