_resize3d
resize_3d
¶
Reshape a tensor
to conform to a given shape.Currently torch doesn't support 16 bit tensors on cpu.
This method can be used with TensorFlow tensors:
t = tf.constant([[[[[0.], [1.]], [[2.], [3.]]], [[[4.], [5.]], [[6.], [7.]]]]])
b = fe.backend.resize_3d(t, output_shape=[3, 3, 3]) # [[[[[0.], [0.], [1.], [1.]], [[0.], [0.], [1.], [1.]], [[2.], [2.], [3.], [3.]], [[2.], [2.], [3.], [3.]]],
[[[0.], [0.], [1.], [1.]], [[0.], [0.], [1.], [1.]], [[2.], [2.], [3.], [3.]], [[2.], [2.], [3.], [3.]]],
[[[4.], [4.], [5.], [5.]], [[4.], [4.], [5.], [5.]], [[6.], [6.], [7.], [7.]], [[6.], [6.], [7.], [7.]]],
[[[4.], [4.], [5.], [5.]], [[4.], [4.], [5.], [5.]], [[6.], [6.], [7.], [7.]], [[6.], [6.], [7.], [7.]]]]]
This method can be used with PyTorch tensors:
p = torch.tensor([[[[[0., 1.], [2., 3.]], [[4., 5.], [6., 7.]]]]])
b = fe.backend.resize_3d(p, output_shape=[3, 3, 3]) # [[[[[0., 0., 1., 1.], [0., 0., 1., 1.], [2., 2., 3., 3.], [2., 2., 3., 3.]],
[[0., 0., 1., 1.], [0., 0., 1., 1.], [2., 2., 3., 3.], [2., 2., 3., 3.]],
[[4., 4., 5., 5.], [4., 4., 5., 5.], [6., 6., 7., 7.], [6., 6., 7., 7.]],
[[4., 4., 5., 5.], [4., 4., 5., 5.], [6., 6., 7., 7.], [6., 6., 7., 7.]]]]]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tensor |
Tensor
|
The input value. |
required |
output_shape |
Sequence[int]
|
The new size of the tensor. |
required |
resize_mode |
str
|
mode to apply for resizing |
'nearest'
|
Returns:
Type | Description |
---|---|
Tensor
|
The resized |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in fastestimator/fastestimator/backend/_resize3d.py
resize_tensorflow_tensor
¶
Resize tensorflow tensor
Input
data: Input tensorflow tensor output_shape: (X, Y, Z) Expected output shape of tensor