NVlabs / tiny-cuda-nn

Lightning fast C++/CUDA neural network framework
Other
3.75k stars 454 forks source link

Input range to a HashGrid #365

Open amitabe opened 1 year ago

amitabe commented 1 year ago

Hi,

What range should the input be in if I'm using the HashGrid encoding? Let's say I have the following sinppet:

config = {
     "encoding": {
        "otype": "HashGrid",
        "n_levels": 16,
        "n_features_per_level": 2,
        "log2_hashmap_size": 19,
        "base_resolution": 16,
        "per_level_scale": 2.0,
    }
}
encoding = tcnn.Encoding(3, config["encoding"])

Then, I want to apply this encoding on a vector x:

x = torch.tensor([[a, b, c]]).cuda()
y = encoding(x)

So, my question is - in what range a,b,c should be in? Should it be in [0,1]? In PyTorch grid_sample it expects the input to be in [-1,1], so is that the case in here to?

I can't find the answer to it anywhere in the documentation or the code, but I might have missed it.

Thanks

amitabe commented 1 year ago

Bumping this question

costrice commented 1 year ago

I also had this question and tried to find out the answer. I think the input range should be [0, 1] according to #286.

txdai commented 11 months ago

This actually works for any input since the hash mapping is from the real plane to a fixed number of hash entries (hence the hash collision). My tests showed that using [0,1] or [-1,1] has no difference

treder commented 6 months ago

Is there any way to change the location + size of the hashgrid, e.g. to [-10, 3] (along each coordinate) while leaving its resolution the same? This is useful when dealing with pre-defined scenes that often have different extent and are not necessarily centered at origin.