Performs `op` on the space-to-batch representation of `input`. This has the effect of transforming sliding window operations into the corresponding "atrous" operation in which the input is sampled at the specified `dilation_rate`. In the special case that `dilation_rate` is uniformly 1, th
(
input, # pylint: disable=redefined-builtin
dilation_rate,
padding,
op,
filter_shape=None,
spatial_dims=None,
data_format=None)
| 339 | |
| 340 | @tf_export("nn.with_space_to_batch") |
| 341 | def with_space_to_batch( |
| 342 | input, # pylint: disable=redefined-builtin |
| 343 | dilation_rate, |
| 344 | padding, |
| 345 | op, |
| 346 | filter_shape=None, |
| 347 | spatial_dims=None, |
| 348 | data_format=None): |
| 349 | """Performs `op` on the space-to-batch representation of `input`. |
| 350 | |
| 351 | This has the effect of transforming sliding window operations into the |
| 352 | corresponding "atrous" operation in which the input is sampled at the |
| 353 | specified `dilation_rate`. |
| 354 | |
| 355 | In the special case that `dilation_rate` is uniformly 1, this simply returns: |
| 356 | |
| 357 | op(input, num_spatial_dims, padding) |
| 358 | |
| 359 | Otherwise, it returns: |
| 360 | |
| 361 | batch_to_space_nd( |
| 362 | op(space_to_batch_nd(input, adjusted_dilation_rate, adjusted_paddings), |
| 363 | num_spatial_dims, |
| 364 | "VALID") |
| 365 | adjusted_dilation_rate, |
| 366 | adjusted_crops), |
| 367 | |
| 368 | where: |
| 369 | |
| 370 | adjusted_dilation_rate is an int64 tensor of shape [max(spatial_dims)], |
| 371 | adjusted_{paddings,crops} are int64 tensors of shape [max(spatial_dims), 2] |
| 372 | |
| 373 | defined as follows: |
| 374 | |
| 375 | We first define two int64 tensors `paddings` and `crops` of shape |
| 376 | `[num_spatial_dims, 2]` based on the value of `padding` and the spatial |
| 377 | dimensions of the `input`: |
| 378 | |
| 379 | If `padding = "VALID"`, then: |
| 380 | |
| 381 | paddings, crops = required_space_to_batch_paddings( |
| 382 | input_shape[spatial_dims], |
| 383 | dilation_rate) |
| 384 | |
| 385 | If `padding = "SAME"`, then: |
| 386 | |
| 387 | dilated_filter_shape = |
| 388 | filter_shape + (filter_shape - 1) * (dilation_rate - 1) |
| 389 | |
| 390 | paddings, crops = required_space_to_batch_paddings( |
| 391 | input_shape[spatial_dims], |
| 392 | dilation_rate, |
| 393 | [(dilated_filter_shape - 1) // 2, |
| 394 | dilated_filter_shape - 1 - (dilated_filter_shape - 1) // 2]) |
| 395 | |
| 396 | Because `space_to_batch_nd` and `batch_to_space_nd` assume that the spatial |
| 397 | dimensions are contiguous starting at the second dimension, but the specified |
| 398 | `spatial_dims` may not be, we must adjust `dilation_rate`, `paddings` and |
no test coverage detected