| 46 | |
| 47 | |
| 48 | def conv(): |
| 49 | in_channels, out_channels, D = 2, 3, 2 |
| 50 | coords, feats, labels = data_loader(in_channels, batch_size=1) |
| 51 | |
| 52 | # Convolution |
| 53 | input = ME.SparseTensor(feats=feats, coords=coords) |
| 54 | conv = ME.MinkowskiConvolution( |
| 55 | in_channels, |
| 56 | out_channels, |
| 57 | kernel_size=3, |
| 58 | stride=2, |
| 59 | has_bias=False, |
| 60 | dimension=D) |
| 61 | |
| 62 | output = conv(input) |
| 63 | |
| 64 | print('Input:') |
| 65 | print_sparse_tensor(input) |
| 66 | |
| 67 | print('Output:') |
| 68 | print_sparse_tensor(output) |
| 69 | |
| 70 | # Convolution transpose and generate new coordinates |
| 71 | strided_coords, tensor_stride = get_random_coords() |
| 72 | |
| 73 | input = ME.SparseTensor( |
| 74 | feats=torch.rand(len(strided_coords), in_channels), # |
| 75 | coords=strided_coords, |
| 76 | tensor_stride=tensor_stride) |
| 77 | conv_tr = ME.MinkowskiConvolutionTranspose( |
| 78 | in_channels, |
| 79 | out_channels, |
| 80 | kernel_size=3, |
| 81 | stride=2, |
| 82 | has_bias=False, |
| 83 | dimension=D) |
| 84 | output = conv_tr(input) |
| 85 | |
| 86 | print('\nInput:') |
| 87 | print_sparse_tensor(input) |
| 88 | |
| 89 | print('Convolution Transpose Output:') |
| 90 | print_sparse_tensor(output) |
| 91 | |
| 92 | |
| 93 | def conv_on_coords(): |