zkytony / cos-pomdp

Code for "Towards Optimal Correlational Object Search" | ICRA 2022
Apache License 2.0
13 stars 5 forks source link

All probabilities are 0 when loading from a file #8

Closed RajeshDM closed 7 months ago

RajeshDM commented 9 months ago

At this line - when all the correlation are being loaded, some of them all have 0 probabilities :

https://github.com/zkytony/cos-pomdp/blob/1e3c7fe940a2165b5c5c384ebf047e8139d437ec/cospomdp/models/correlation.py#L83

You can test this by running the following function :

def load(loadpath):
    with open(loadpath, "rb") as f:
        data = pickle.load(f)
    dists = {}
    for starget in data['dists']:
        weights = data['dists'][starget]
        dist = TabularDistribution([data['corr_object'][0]],
                                    weights, normalize=True)
        dists[starget] = dist

    for dist in dists.values():
        if sum(dist.histogram.values()) == 0 :
            candidates = list(dist.histogram.keys())
            prob_dist = []
            for value in candidates:
                prob_dist.append(dist.histogram[value])
           print (random.choices(candidates, weights=prob_dist, k=1)[0],sum(prob_dist))

This is basically happening right after the corelation probabilities being loaded - so it looks like the stored data has the 0s

This can easily be reproduced by running the default scene itself

zkytony commented 9 months ago

Thanks. Could you print out what classes the correlation probabilities are for? It is possible that those two classes have never appeared together (or, for some similar semantic reasons).

I believe you can find out the classes by printing data.

RajeshDM commented 9 months ago

Hi,

ObjectState::(AlarmClock,{'loc': (8, 9), 'id': 'AlarmClock'}) ['DeskLamp'] ObjectState::(AlarmClock,{'loc': (7, 9), 'id': 'AlarmClock'}) ['DeskLamp'] ObjectState::(AlarmClock,{'loc': (7, 8), 'id': 'AlarmClock'}) ['DeskLamp']

This is a set of objects for which all probabilities are 0 - so it looks like alarm clock and desk lamp have correlation as 0 in some cases. Please let me know if any other information would be useful

zkytony commented 9 months ago

It's possible that AlarmClock and DeskLamp never occured together in any of the scenes used to collect the correlations. Perhaps this is due to scene changes in newer Ai2thor versions, but I am not certain. For now, you could just skip loading these.

RajeshDM commented 9 months ago

It's possible that AlarmClock and DeskLamp never occured together in any of the scenes used to collect the correlations. Perhaps this is due to scene changes in newer Ai2thor versions, but I am not certain. For now, you could just skip loading these.

This is happening in all versions of AI2Thor (I tried it with old and new). This issue doesn't have anything to do with AI2Thor or python.

(The final behaviour is different in a newer version of python because what happens in random.choices is different when everything is 0 is different in python 3.9 onwards. But otherwise - the fact that everything is 0 is consistent across AI2Thor and python versions)

zkytony commented 8 months ago

I see. I hope skipping helps!