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

Method build

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

Source from the content-addressed store, hash-verified

1299 self.pointwise_constraint = constraints.get(pointwise_constraint)
1300
1301 def build(self, input_shape):
1302 input_shape = tensor_shape.TensorShape(input_shape)
1303 if self.data_format == 'channels_first':
1304 channel_axis = 1
1305 else:
1306 channel_axis = -1
1307 if input_shape.dims[channel_axis].value is None:
1308 raise ValueError('The channel dimension of the inputs '
1309 'should be defined. Found `None`.')
1310 input_dim = int(input_shape[channel_axis])
1311 self.input_spec = InputSpec(ndim=self.rank + 2,
1312 axes={channel_axis: input_dim})
1313 depthwise_kernel_shape = self.kernel_size + (input_dim,
1314 self.depth_multiplier)
1315 pointwise_kernel_shape = (
1316 1,) * self.rank + (self.depth_multiplier * input_dim, self.filters)
1317
1318 self.depthwise_kernel = self.add_weight(
1319 name='depthwise_kernel',
1320 shape=depthwise_kernel_shape,
1321 initializer=self.depthwise_initializer,
1322 regularizer=self.depthwise_regularizer,
1323 constraint=self.depthwise_constraint,
1324 trainable=True,
1325 dtype=self.dtype)
1326 self.pointwise_kernel = self.add_weight(
1327 name='pointwise_kernel',
1328 shape=pointwise_kernel_shape,
1329 initializer=self.pointwise_initializer,
1330 regularizer=self.pointwise_regularizer,
1331 constraint=self.pointwise_constraint,
1332 trainable=True,
1333 dtype=self.dtype)
1334 if self.use_bias:
1335 self.bias = self.add_weight(
1336 name='bias',
1337 shape=(self.filters,),
1338 initializer=self.bias_initializer,
1339 regularizer=self.bias_regularizer,
1340 constraint=self.bias_constraint,
1341 trainable=True,
1342 dtype=self.dtype)
1343 else:
1344 self.bias = None
1345 self.built = True
1346
1347 def call(self, inputs):
1348 raise NotImplementedError

Callers

nothing calls this directly

Calls 2

InputSpecClass · 0.90
add_weightMethod · 0.45

Tested by

no test coverage detected