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

Function local_conv

tensorflow/python/keras/backend.py:5223–5297  ·  view source on GitHub ↗

Apply N-D convolution with un-shared weights. Arguments: inputs: (N+2)-D tensor with shape (batch_size, channels_in, d_in1, ..., d_inN) if data_format='channels_first', or (batch_size, d_in1, ..., d_inN, channels_in) if data_format='channels_last'.

(inputs,
               kernel,
               kernel_size,
               strides,
               output_shape,
               data_format=None)

Source from the content-addressed store, hash-verified

5221
5222
5223def local_conv(inputs,
5224 kernel,
5225 kernel_size,
5226 strides,
5227 output_shape,
5228 data_format=None):
5229 """Apply N-D convolution with un-shared weights.
5230
5231 Arguments:
5232 inputs: (N+2)-D tensor with shape
5233 (batch_size, channels_in, d_in1, ..., d_inN)
5234 if data_format='channels_first', or
5235 (batch_size, d_in1, ..., d_inN, channels_in)
5236 if data_format='channels_last'.
5237 kernel: the unshared weight for N-D convolution,
5238 with shape (output_items, feature_dim, channels_out), where
5239 feature_dim = np.prod(kernel_size) * channels_in,
5240 output_items = np.prod(output_shape).
5241 kernel_size: a tuple of N integers, specifying the
5242 spatial dimensions of the N-D convolution window.
5243 strides: a tuple of N integers, specifying the strides
5244 of the convolution along the spatial dimensions.
5245 output_shape: a tuple of (d_out1, ..., d_outN) specifying the spatial
5246 dimensionality of the output.
5247 data_format: string, "channels_first" or "channels_last".
5248
5249 Returns:
5250 An (N+2)-D tensor with shape:
5251 (batch_size, channels_out) + output_shape
5252 if data_format='channels_first', or:
5253 (batch_size,) + output_shape + (channels_out,)
5254 if data_format='channels_last'.
5255
5256 Raises:
5257 ValueError: if `data_format` is neither
5258 `channels_last` nor `channels_first`.
5259 """
5260 if data_format is None:
5261 data_format = image_data_format()
5262 if data_format not in {'channels_first', 'channels_last'}:
5263 raise ValueError('Unknown data_format: ' + str(data_format))
5264
5265 kernel_shape = int_shape(kernel)
5266 feature_dim = kernel_shape[1]
5267 channels_out = kernel_shape[-1]
5268 ndims = len(output_shape)
5269 spatial_dimensions = list(range(ndims))
5270
5271 xs = []
5272 output_axes_ticks = [range(axis_max) for axis_max in output_shape]
5273 for position in itertools.product(*output_axes_ticks):
5274 slices = [slice(None)]
5275
5276 if data_format == 'channels_first':
5277 slices.append(slice(None))
5278
5279 slices.extend([slice(position[d] * strides[d],
5280 position[d] * strides[d] + kernel_size[d])

Callers 2

local_conv1dFunction · 0.85
local_conv2dFunction · 0.85

Calls 11

image_data_formatFunction · 0.85
int_shapeFunction · 0.85
batch_dotFunction · 0.85
permute_dimensionsFunction · 0.85
productMethod · 0.80
reshapeFunction · 0.70
concatenateFunction · 0.70
rangeFunction · 0.50
sliceFunction · 0.50
appendMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected