Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use the spnn.Conv3d #295

Open
qifeng22 opened this issue Mar 9, 2024 · 1 comment
Open

Can't use the spnn.Conv3d #295

qifeng22 opened this issue Mar 9, 2024 · 1 comment
Assignees

Comments

@qifeng22
Copy link

qifeng22 commented Mar 9, 2024

import random
from typing import Any, Dict

import numpy as np
import torch
import torch.utils.data
from torch import nn
from torch.cuda import amp

import torchsparse
from torchsparse import SparseTensor
from torchsparse import nn as spnn
from torchsparse.nn import functional as F
from torchsparse.utils.collate import sparse_collate_fn
from torchsparse.utils.quantize import sparse_quantize


inputs = np.random.uniform(-10, 10, size=(10, 4))

coords, feats = inputs[:, :3], inputs

coords -= np.min(coords, axis=0, keepdims=True)

coords, indices = sparse_quantize(coords, 0.01, return_index=True)

coords = torch.tensor(coords, dtype=torch.int)
feats = torch.tensor(feats[indices], dtype=torch.float)


input = SparseTensor(coords=coords, feats=feats)

tt = spnn.Conv3d(4, 3, 1,stride=2).cuda()(input)
print(tt.feats)

image

@zhijian-liu
Copy link

For SparseTensor, the 'coords' need to be a four-channel vector, where the first three dimensions represent the voxelized coordinates, and the last one should indicate the batch index.

@zhijian-liu zhijian-liu self-assigned this May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants