Giter Club home page Giter Club logo

Comments (4)

francois-rozet avatar francois-rozet commented on June 16, 2024 1

Ok this seems like a bug, I will look into it. However, I notice that your bins have a uniform width. So instead of using edges you can provide bins, low and upp. This should fix the issue as the quantize function does not rely on searchsorted.

from torchist.

francois-rozet avatar francois-rozet commented on June 16, 2024

Hello, thank you for the report. It seems like you are using edges instead of bins to define the shape of your histogram (30x32x30). The edges argument should be a tensor whose elements are the edges of each bins. If you wanted to divide the [0, 1] interval in 3 bins of width 0.25, 0.5 and 0.25 respectively, you would have

edges = torch.tensor([0.0, 0.25, 0.75, 0.1])

In particular, the elements of edges should be strictly increasing. In your case, (I guess that) you want to divide the dimensions into, respectively, 30, 32 and 30 bins of uniform width. Then, you should use bins instead of edges:

h0 = torchist.histogramdd(input, edges=[30, 32, 30], weights=weights)

Tell me if this helps. Note that I have just released a newer version (0.2.0) of the package.

from torchist.

WilliamKorcari avatar WilliamKorcari commented on June 16, 2024

Thank you for your reply. I am sorry I misreported my code trying to reduce it to the minimum necessary amount. I actually use edges the proper way and the code looks like this

>>> inputs = torch.stack([y[i], x[i], z[i]], -1)  # shape [4000, 3]
>>> weights = w[i]                                # shape [4000]
>>> edges = [torch.arange(31)*0.5250244140625, torch.arange(-81, 82, 5.088333), torch.arange(-77+5.088333*8, 78+5.088333*8, 5.088333)] # shape [31, 32, 31] and strictly increasing. 
>>> h0 = torchist.histogramdd(inputs, edges=edges, weights=weights)

I also adjusted the edges to have the same size [31,31,31], even though by reading your nice code I found it should not be necessary and the code still "randomly" fails. I also looked at the tensors that cause the break, but they have nothing special with respect to the others (all float tensors, no NaN).

After spending some time trying to figure out what is going on, I guessed that maybe something goes wrong with the torch.searchsorted method because from the error I posted the value 29358 is clearly bigger than 30x32x30 = 28800 but I don't understand where such value could be coming from.

I will try the updated version too, in order to see if this is sorted out. Thanks again for any help you can provide :)

from torchist.

WilliamKorcari avatar WilliamKorcari commented on June 16, 2024

Thank you for the tip!

from torchist.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.