MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _WithSpaceToBatch

Class _WithSpaceToBatch

tensorflow/python/ops/nn_ops.py:500–662  ·  view source on GitHub ↗

Helper class for with_space_to_batch. Note that this class assumes that shapes of input and filter passed to __call__ are compatible with input_shape and filter_shape passed to the constructor. Arguments input_shape: static shape of input. i.e. input.get_shape(). dilation_rate: see

Source from the content-addressed store, hash-verified

498
499
500class _WithSpaceToBatch(object):
501 """Helper class for with_space_to_batch.
502
503 Note that this class assumes that shapes of input and filter passed to
504 __call__ are compatible with input_shape and filter_shape passed to the
505 constructor.
506
507 Arguments
508 input_shape: static shape of input. i.e. input.get_shape().
509 dilation_rate: see with_space_to_batch
510 padding: see with_space_to_batch
511 build_op: Function that maps (num_spatial_dims, paddings) -> (function that
512 maps (input, filter) -> output).
513 filter_shape: see with_space_to_batch
514 spatial_dims: see with_space_to_batch
515 data_format: see with_space_to_batch
516 """
517
518 def __init__(self,
519 input_shape,
520 dilation_rate,
521 padding,
522 build_op,
523 filter_shape=None,
524 spatial_dims=None,
525 data_format=None,
526 fused=False):
527 """Helper class for _with_space_to_batch."""
528 dilation_rate = ops.convert_to_tensor(
529 dilation_rate, dtypes.int32, name="dilation_rate")
530 try:
531 rate_shape = dilation_rate.get_shape().with_rank(1)
532 except ValueError:
533 raise ValueError("rate must be rank 1")
534
535 if not dilation_rate.get_shape().is_fully_defined():
536 raise ValueError("rate must have known shape")
537
538 num_spatial_dims = rate_shape.dims[0].value
539
540 if data_format is not None and data_format.startswith("NC"):
541 starting_spatial_dim = 2
542 else:
543 starting_spatial_dim = 1
544
545 if spatial_dims is None:
546 spatial_dims = range(starting_spatial_dim,
547 num_spatial_dims + starting_spatial_dim)
548 orig_spatial_dims = list(spatial_dims)
549 spatial_dims = sorted(set(int(x) for x in orig_spatial_dims))
550 if spatial_dims != orig_spatial_dims or any(x < 1 for x in spatial_dims):
551 raise ValueError(
552 "spatial_dims must be a montonically increasing sequence of positive "
553 "integers")
554
555 if data_format is not None and data_format.startswith("NC"):
556 expected_input_rank = spatial_dims[-1]
557 else:

Callers 2

with_space_to_batchFunction · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected