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

Method __init__

tensorflow/python/ops/nn_ops.py:1069–1139  ·  view source on GitHub ↗

Helper function for convolution.

(self,
               input_shape,
               filter_shape,
               padding,
               strides=None,
               dilation_rate=None,
               name=None,
               data_format=None,
               fused=False)

Source from the content-addressed store, hash-verified

1067 """
1068
1069 def __init__(self,
1070 input_shape,
1071 filter_shape,
1072 padding,
1073 strides=None,
1074 dilation_rate=None,
1075 name=None,
1076 data_format=None,
1077 fused=False):
1078 """Helper function for convolution."""
1079 num_total_dims = filter_shape.ndims
1080 if num_total_dims is None:
1081 num_total_dims = input_shape.ndims
1082 if num_total_dims is None:
1083 raise ValueError("rank of input or filter must be known")
1084
1085 num_spatial_dims = num_total_dims - 2
1086
1087 try:
1088 input_shape.with_rank(num_spatial_dims + 2)
1089 except ValueError:
1090 raise ValueError(
1091 "input tensor must have rank %d" % (num_spatial_dims + 2))
1092
1093 try:
1094 filter_shape.with_rank(num_spatial_dims + 2)
1095 except ValueError:
1096 raise ValueError(
1097 "filter tensor must have rank %d" % (num_spatial_dims + 2))
1098
1099 if data_format is None or not data_format.startswith("NC"):
1100 input_channels_dim = tensor_shape.dimension_at_index(
1101 input_shape, num_spatial_dims + 1)
1102 spatial_dims = range(1, num_spatial_dims + 1)
1103 else:
1104 input_channels_dim = tensor_shape.dimension_at_index(input_shape, 1)
1105 spatial_dims = range(2, num_spatial_dims + 2)
1106
1107 if not input_channels_dim.is_compatible_with(
1108 filter_shape[num_spatial_dims]):
1109 raise ValueError(
1110 "number of input channels does not match corresponding dimension of "
1111 "filter, {} != {}".format(input_channels_dim,
1112 filter_shape[num_spatial_dims]))
1113
1114 strides, dilation_rate = _get_strides_and_dilation_rate(
1115 num_spatial_dims, strides, dilation_rate)
1116
1117 self.input_shape = input_shape
1118 self.filter_shape = filter_shape
1119 self.data_format = data_format
1120 self.strides = strides
1121 self.padding = padding
1122 self.name = name
1123 self.dilation_rate = dilation_rate
1124 # We call CUDNN convolutions when dealing with convolutions with 1D/2D
1125 # space + dilation or convolutions with no dilation. CUDNN is not used for
1126 # 3D convolutions with dilation because that would result in "no algorithm

Callers

nothing calls this directly

Calls 6

_WithSpaceToBatchClass · 0.85
with_rankMethod · 0.80
rangeFunction · 0.70
is_compatible_withMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected