Python tensorflow.python.ops.nn.separable_conv2d() Examples
The following are 6
code examples of tensorflow.python.ops.nn.separable_conv2d().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow.python.ops.nn
, or try the search function
.
Example #1
Source File: convolutional.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 6 votes |
def call(self, inputs): # Apply the actual ops. if self.data_format == 'channels_last': strides = (1,) + self.strides + (1,) else: strides = (1, 1) + self.strides outputs = nn.separable_conv2d( inputs, self.depthwise_kernel, self.pointwise_kernel, strides=strides, padding=self.padding.upper(), rate=self.dilation_rate, data_format=utils.convert_data_format(self.data_format, ndim=4)) if self.use_bias: outputs = nn.bias_add( outputs, self.bias, data_format=utils.convert_data_format(self.data_format, ndim=4)) if self.activation is not None: return self.activation(outputs) return outputs
Example #2
Source File: convolutional.py From lambda-packs with MIT License | 5 votes |
def call(self, inputs): if self.data_format == 'channels_first': # Reshape to channels last inputs = array_ops.transpose(inputs, (0, 2, 3, 1)) # Apply the actual ops. outputs = nn.separable_conv2d( inputs, self.depthwise_kernel, self.pointwise_kernel, strides=(1,) + self.strides + (1,), padding=self.padding.upper(), rate=self.dilation_rate) if self.data_format == 'channels_first': # Reshape to channels first outputs = array_ops.transpose(outputs, (0, 3, 1, 2)) if self.bias is not None: outputs = nn.bias_add( outputs, self.bias, data_format=utils.convert_data_format(self.data_format, ndim=4)) if self.activation is not None: return self.activation(outputs) return outputs
Example #3
Source File: convolutional.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def call(self, inputs): if self.data_format == 'channels_first': # Reshape to channels last inputs = array_ops.transpose(inputs, (0, 2, 3, 1)) # Apply the actual ops. outputs = nn.separable_conv2d( inputs, self.depthwise_kernel, self.pointwise_kernel, strides=(1,) + self.strides + (1,), padding=self.padding.upper(), rate=self.dilation_rate) if self.data_format == 'channels_first': # Reshape to channels first outputs = array_ops.transpose(outputs, (0, 3, 1, 2)) if self.bias: outputs = nn.bias_add( outputs, self.bias, data_format=utils.convert_data_format(self.data_format, ndim=4)) if self.activation is not None: return self.activation(outputs) return outputs
Example #4
Source File: convolutional.py From keras-lambda with MIT License | 5 votes |
def call(self, inputs): if self.data_format == 'channels_first': # Reshape to channels last inputs = array_ops.transpose(inputs, (0, 2, 3, 1)) # Apply the actual ops. outputs = nn.separable_conv2d( inputs, self.depthwise_kernel, self.pointwise_kernel, strides=(1,) + self.strides + (1,), padding=self.padding.upper(), rate=self.dilation_rate) if self.data_format == 'channels_first': # Reshape to channels first outputs = array_ops.transpose(outputs, (0, 3, 1, 2)) if self.bias: outputs = nn.bias_add( outputs, self.bias, data_format=utils.convert_data_format(self.data_format, ndim=4)) if self.activation is not None: return self.activation(outputs) return outputs
Example #5
Source File: backend.py From lambda-packs with MIT License | 4 votes |
def separable_conv2d(x, depthwise_kernel, pointwise_kernel, strides=(1, 1), padding='valid', data_format=None, dilation_rate=(1, 1)): """2D convolution with separable filters. Arguments: x: input tensor depthwise_kernel: convolution kernel for the depthwise convolution. pointwise_kernel: kernel for the 1x1 convolution. strides: strides tuple (length 2). padding: padding mode, "valid" or "same". data_format: data format, "channels_first" or "channels_last". dilation_rate: tuple of integers, dilation rates for the separable convolution. Returns: Output tensor. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) x = _preprocess_conv2d_input(x, data_format) padding = _preprocess_padding(padding) strides = (1,) + strides + (1,) x = nn.separable_conv2d( x, depthwise_kernel, pointwise_kernel, strides=strides, padding=padding, rate=dilation_rate) return _postprocess_conv2d_output(x, data_format)
Example #6
Source File: backend.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 4 votes |
def separable_conv2d(x, depthwise_kernel, pointwise_kernel, strides=(1, 1), padding='valid', data_format=None, dilation_rate=(1, 1)): """2D convolution with separable filters. Arguments: x: input tensor depthwise_kernel: convolution kernel for the depthwise convolution. pointwise_kernel: kernel for the 1x1 convolution. strides: strides tuple (length 2). padding: padding mode, "valid" or "same". data_format: data format, "channels_first" or "channels_last". dilation_rate: tuple of integers, dilation rates for the separable convolution. Returns: Output tensor. Raises: ValueError: if `data_format` is neither `channels_last` or `channels_first`. """ if data_format is None: data_format = image_data_format() if data_format not in {'channels_first', 'channels_last'}: raise ValueError('Unknown data_format ' + str(data_format)) x = _preprocess_conv2d_input(x, data_format) padding = _preprocess_padding(padding) strides = (1,) + strides + (1,) x = nn.separable_conv2d( x, depthwise_kernel, pointwise_kernel, strides=strides, padding=padding, rate=dilation_rate) return _postprocess_conv2d_output(x, data_format)