if self.data_format == 'channels_first': height = self.size[0] * input_shape[2] if input_shape[ 2] is not None else None width = self.size[1] * input_shape[3] if input_shape[ 3] is not None else None return tensor_shape.TensorShape( [input_shape[0], input_shape[1], height, width]) else: height = self.size[0] * input_shape[1] if input_shape[ 1] is not None else None width = self.size[1] * input_shape[2] if input_shape[ 2] is not None else None return tensor_shape.TensorShape( [input_shape[0], height, width, input_shape[3]]) def call(self, inputs): return resize_images_bilinear(inputs, self.size[0], self.size[1], self.data_format) def get_config(self): config = {'size': self.size, 'data_format': self.data_format} base_config = super(BilinearUpSampling2D, self).get_config() return dict(list(base_config.items()) + list(config.items())) # add this to custom objects for restoring model save files get_custom_objects().update({ 'SeparableConv2DKeras': SeparableConv2DKeras, 'BilinearUpSampling2D': BilinearUpSampling2D })
height = self.size[0] * input_shape[2] if input_shape[ 2] is not None else None width = self.size[1] * input_shape[3] if input_shape[ 3] is not None else None return tensor_shape.TensorShape( [input_shape[0], input_shape[1], height, width]) else: height = self.size[0] * input_shape[1] if input_shape[ 1] is not None else None width = self.size[1] * input_shape[2] if input_shape[ 2] is not None else None return tensor_shape.TensorShape( [input_shape[0], height, width, input_shape[3]]) def call(self, inputs): output_layer = depth_to_space(inputs, block_size=self.size) return output_layer def get_config(self): config = {'size': self.size, 'data_format': self.data_format} base_config = super(DepthToSpace, self).get_config() return dict(list(base_config.items()) + list(config.items())) # add this to custom objects for restoring model save files get_custom_objects().update({ 'SeparableConv2DKeras': SeparableConv2DKeras, 'BilinearUpSampling2D': BilinearUpSampling2D, 'DepthToSpace': DepthToSpace })
activations.serialize(self.activation), 'use_bias': self.use_bias, 'depthwise_initializer': initializers.serialize(self.depthwise_initializer), 'pointwise_initializer': initializers.serialize(self.pointwise_initializer), 'bias_initializer': initializers.serialize(self.bias_initializer), 'depthwise_regularizer': regularizers.serialize(self.depthwise_regularizer), 'pointwise_regularizer': regularizers.serialize(self.pointwise_regularizer), 'bias_regularizer': regularizers.serialize(self.bias_regularizer), 'activity_regularizer': regularizers.serialize(self.activity_regularizer), 'depthwise_constraint': constraints.serialize(self.depthwise_constraint), 'pointwise_constraint': constraints.serialize(self.pointwise_constraint), 'bias_constraint': constraints.serialize(self.bias_constraint) } base_config = super(SeparableConv2DKeras, self).get_config() return dict(list(base_config.items()) + list(config.items())) # add this to custom objects for restoring model save files get_custom_objects().update({'SeparableConv2DKeras': SeparableConv2DKeras})
cols = input_shape[2] rows = conv_utils.conv_output_length(rows, self.kernel_size[0], self.padding, self.strides[0]) cols = conv_utils.conv_output_length(cols, self.kernel_size[1], self.padding, self.strides[1]) if self.data_format == 'channels_first': return tensor_shape.TensorShape( [input_shape[0], self.filters, rows, cols]) else: return tensor_shape.TensorShape( [input_shape[0], rows, cols, self.filters]) def get_config(self): config = super(DepthWiseConv2D, self).get_config() config.pop('kernel_initializer') config.pop('kernel_regularizer') config.pop('kernel_constraint') config['depth_multiplier'] = self.depth_multiplier config['depthwise_initializer'] = initializers.serialize( self.depthwise_initializer) config['depthwise_regularizer'] = regularizers.serialize( self.depthwise_regularizer) config['depthwise_constraint'] = constraints.serialize( self.depthwise_constraint) return config # add this to custom objects for restoring model save files get_custom_objects().update({'DepthWiseConv2D': DepthWiseConv2D})