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

Method build

tensorflow/python/keras/layers/convolutional.py:1794–1830  ·  view source on GitHub ↗
(self, input_shape)

Source from the content-addressed store, hash-verified

1792 self.bias_initializer = initializers.get(bias_initializer)
1793
1794 def build(self, input_shape):
1795 if len(input_shape) < 4:
1796 raise ValueError('Inputs to `DepthwiseConv2D` should have rank 4. '
1797 'Received input shape:', str(input_shape))
1798 input_shape = tensor_shape.TensorShape(input_shape)
1799 if self.data_format == 'channels_first':
1800 channel_axis = 1
1801 else:
1802 channel_axis = 3
1803 if input_shape.dims[channel_axis].value is None:
1804 raise ValueError('The channel dimension of the inputs to '
1805 '`DepthwiseConv2D` '
1806 'should be defined. Found `None`.')
1807 input_dim = int(input_shape[channel_axis])
1808 depthwise_kernel_shape = (self.kernel_size[0],
1809 self.kernel_size[1],
1810 input_dim,
1811 self.depth_multiplier)
1812
1813 self.depthwise_kernel = self.add_weight(
1814 shape=depthwise_kernel_shape,
1815 initializer=self.depthwise_initializer,
1816 name='depthwise_kernel',
1817 regularizer=self.depthwise_regularizer,
1818 constraint=self.depthwise_constraint)
1819
1820 if self.use_bias:
1821 self.bias = self.add_weight(shape=(input_dim * self.depth_multiplier,),
1822 initializer=self.bias_initializer,
1823 name='bias',
1824 regularizer=self.bias_regularizer,
1825 constraint=self.bias_constraint)
1826 else:
1827 self.bias = None
1828 # Set input spec.
1829 self.input_spec = InputSpec(ndim=4, axes={channel_axis: input_dim})
1830 self.built = True
1831
1832 def call(self, inputs):
1833 outputs = backend.depthwise_conv2d(

Callers

nothing calls this directly

Calls 2

InputSpecClass · 0.90
add_weightMethod · 0.45

Tested by

no test coverage detected