Python tensorflow.python.ops.array_ops.batch_to_space_nd() Examples
The following are 7
code examples of tensorflow.python.ops.array_ops.batch_to_space_nd().
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.array_ops
, or try the search function
.
Example #1
Source File: array_grad.py From lambda-packs with MIT License | 5 votes |
def _SpaceToBatchNDGrad(op, grad): # Its gradient is the opposite op: BatchToSpaceND. return [array_ops.batch_to_space_nd(grad, op.inputs[1], op.inputs[2]), None, None]
Example #2
Source File: array_grad.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def _SpaceToBatchNDGrad(op, grad): # Its gradient is the opposite op: BatchToSpaceND. return [array_ops.batch_to_space_nd(grad, op.inputs[1], op.inputs[2]), None, None]
Example #3
Source File: array_grad.py From deep_image_model with Apache License 2.0 | 5 votes |
def _SpaceToBatchNDGrad(op, grad): # Its gradient is the opposite op: BatchToSpaceND. return [array_ops.batch_to_space_nd(grad, op.inputs[1], op.inputs[2]), None, None]
Example #4
Source File: test_forward.py From incubator-tvm with Apache License 2.0 | 5 votes |
def _test_batch_to_space_nd(input_shape, block_shape, crops, dtype='int32'): data = np.random.uniform(0, 5, size=input_shape).astype(dtype) with tf.Graph().as_default(): in_data = array_ops.placeholder(shape=input_shape, dtype=dtype) out = array_ops.batch_to_space_nd(in_data, block_shape, crops) compare_tflite_with_tvm(data, 'Placeholder:0', [in_data], [out])
Example #5
Source File: array_grad.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def _SpaceToBatchNDGrad(op, grad): # Its gradient is the opposite op: BatchToSpaceND. return [array_ops.batch_to_space_nd(grad, op.inputs[1], op.inputs[2]), None, None]
Example #6
Source File: array_grad.py From keras-lambda with MIT License | 5 votes |
def _SpaceToBatchNDGrad(op, grad): # Its gradient is the opposite op: BatchToSpaceND. return [array_ops.batch_to_space_nd(grad, op.inputs[1], op.inputs[2]), None, None]
Example #7
Source File: nn_ops.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 4 votes |
def _with_space_to_batch_call(self, inp, filter): # pylint: disable=redefined-builtin """Call functionality for with_space_to_batch.""" # Handle input whose shape is unknown during graph creation. input_spatial_shape = None input_shape = self.input_shape spatial_dims = self.spatial_dims if input_shape.ndims is not None: input_shape_list = input_shape.as_list() input_spatial_shape = [input_shape_list[i] for i in spatial_dims] if input_spatial_shape is None or None in input_spatial_shape: input_shape_tensor = array_ops.shape(inp) input_spatial_shape = array_ops.stack( [input_shape_tensor[i] for i in spatial_dims]) base_paddings = self.base_paddings if base_paddings is None: # base_paddings could not be computed at build time since static filter # shape was not fully defined. filter_shape = array_ops.shape(filter) base_paddings = _with_space_to_batch_base_paddings( filter_shape, self.num_spatial_dims, self.rate_or_const_rate) paddings, crops = array_ops.required_space_to_batch_paddings( input_shape=input_spatial_shape, base_paddings=base_paddings, block_shape=self.dilation_rate) dilation_rate = _with_space_to_batch_adjust(self.dilation_rate, 1, spatial_dims) paddings = _with_space_to_batch_adjust(paddings, 0, spatial_dims) crops = _with_space_to_batch_adjust(crops, 0, spatial_dims) input_converted = array_ops.space_to_batch_nd( input=inp, block_shape=dilation_rate, paddings=paddings) result = self.op(input_converted, filter) result_converted = array_ops.batch_to_space_nd( input=result, block_shape=dilation_rate, crops=crops) return result_converted