tfp.experimental.nn.util.im2row
Stay organized with collections
Save and categorize content based on your preferences.
Rearrange image blocks into rows.
tfp.experimental.nn.util.im2row(
x, block_shape, slice_step=(1, 1), padding='VALID', name=None
)
This function can be used to implement 2D convolution as a matmul
, e.g.,
tf.nn.conv2d(x, k) = tf.matmul(
tf.experimental.nn.util.im2row(x), tf.reshape(k, shape=[-1, out_size]))
.
Args |
x
|
Rank 3 (or more) Tensor representing 2D images.
|
block_shape
|
Length-2 vector representing the block or "filter" shape.
|
slice_step
|
Length-2 vector specifying the convolution stride length.
Default value: (1, 1) .
|
padding
|
One of 'VALID' or 'SAME' (case insensitive).
Default value: 'VALID' .
|
name
|
Python str used to describe ops created by this function.
Default value: None (i.e., 'im2col' ).
|
Returns |
im2row_x
|
batch of matrices representing subblock copies of x .
Same batch shape as x but with rightmost shape:
batch_shape + [oh * ow, block_shape[0] * block_shape[1] * channels] ,
where oh = (h - block_shape[0] + 1) // slice_step[0] and
ow = (w - block_shape[1] + 1) // slice_step[1] when padding = 'VALID'
and oh = h and ow = w when padding = 'SAME' .
|
shape
|
shape Tensor equivalent to:
batch_shape + [oh, ow, block_shape[0] * block_shape[1] * channels] where
oh, ow are defined as above.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-11-21 UTC."],[],[]]