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

Class Convolution

tensorflow/python/ops/nn_ops.py:1052–1178  ·  view source on GitHub ↗

Helper class for convolution. 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(). filter_shape: static shape

Source from the content-addressed store, hash-verified

1050
1051
1052class Convolution(object):
1053 """Helper class for convolution.
1054
1055 Note that this class assumes that shapes of input and filter passed to
1056 __call__ are compatible with input_shape and filter_shape passed to the
1057 constructor.
1058
1059 Arguments
1060 input_shape: static shape of input. i.e. input.get_shape().
1061 filter_shape: static shape of the filter. i.e. filter.get_shape().
1062 padding: see convolution.
1063 strides: see convolution.
1064 dilation_rate: see convolution.
1065 name: see convolution.
1066 data_format: see convolution.
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(

Callers 5

convolution_internalFunction · 0.70
TEST_FFunction · 0.50
TEST_PFunction · 0.50
TEST_FFunction · 0.50
TESTFunction · 0.50

Calls

no outgoing calls

Tested by 4

TEST_FFunction · 0.40
TEST_PFunction · 0.40
TEST_FFunction · 0.40
TESTFunction · 0.40