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

Method build

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

Source from the content-addressed store, hash-verified

763 str(self.output_padding))
764
765 def build(self, input_shape):
766 input_shape = tensor_shape.TensorShape(input_shape)
767 if len(input_shape) != 4:
768 raise ValueError('Inputs should have rank 4. Received input shape: ' +
769 str(input_shape))
770 if self.data_format == 'channels_first':
771 channel_axis = 1
772 else:
773 channel_axis = -1
774 if input_shape.dims[channel_axis].value is None:
775 raise ValueError('The channel dimension of the inputs '
776 'should be defined. Found `None`.')
777 input_dim = int(input_shape[channel_axis])
778 self.input_spec = InputSpec(ndim=4, axes={channel_axis: input_dim})
779 kernel_shape = self.kernel_size + (self.filters, input_dim)
780
781 self.kernel = self.add_weight(
782 name='kernel',
783 shape=kernel_shape,
784 initializer=self.kernel_initializer,
785 regularizer=self.kernel_regularizer,
786 constraint=self.kernel_constraint,
787 trainable=True,
788 dtype=self.dtype)
789 if self.use_bias:
790 self.bias = self.add_weight(
791 name='bias',
792 shape=(self.filters,),
793 initializer=self.bias_initializer,
794 regularizer=self.bias_regularizer,
795 constraint=self.bias_constraint,
796 trainable=True,
797 dtype=self.dtype)
798 else:
799 self.bias = None
800 self.built = True
801
802 def call(self, inputs):
803 inputs_shape = array_ops.shape(inputs)

Calls 2

InputSpecClass · 0.90
add_weightMethod · 0.45