csmith49 / clevr-caption

Python wrapper for the CLEVR dataset
0 stars 0 forks source link

Logic core over flow in bind #2

Open moqingyan opened 4 years ago

moqingyan commented 4 years ago

Hey Calvin,

I found some strange cases, even the clause number does not grow over 10, the greedy algorithm meets stack overflow in the logic core.

Here is the scene:

{"objects": [{"size": "large", "color": "red", "shape": "cube", "material": "metal"}, {"size": "small", "color": "yellow", "shape": "cylinder", "material": "metal"}, {"size": "large", "color": "yellow", "shape": "sphere", "material": "rubber"}, {"size": "small", "color": "brown", "shape": "cube", "material": "metal"}, {"size": "small", "color": "green", "shape": "cube", "material": "metal"}, {"size": "small", "color": "red", "shape": "sphere", "material": "metal"}, {"size": "large", "color": "green", "shape": "sphere", "material": "rubber"}, {"size": "small", "color": "cyan", "shape": "cube", "material": "metal"}, {"size": "small", "color": "cyan", "shape": "cube", "material": "rubber"}, {"size": "small", "color": "brown", "shape": "cylinder", "material": "rubber"}], "relationships": {"right": [[2], [7, 6, 8, 3, 5, 9, 4, 0, 2], [], [5, 9, 4, 0, 2], [0, 2], [9, 4, 0, 2], [8, 3, 5, 9, 4, 0, 2], [6, 8, 3, 5, 9, 4, 0, 2], [3, 5, 9, 4, 0, 2], [4, 0, 2]], "behind": [[1, 7, 6, 8, 3, 5, 9, 4], [], [1, 7, 6, 8, 3, 5, 9, 4, 0], [1, 7, 6, 8], [1, 7, 6, 8, 3, 5, 9], [1, 7, 6, 8, 3], [1, 7], [1], [1, 7, 6], [1, 7, 6, 8, 3, 5]], "front": [[2], [7, 6, 8, 3, 5, 9, 4, 0, 2], [], [5, 9, 4, 0, 2], [0, 2], [9, 4, 0, 2], [8, 3, 5, 9, 4, 0, 2], [6, 8, 3, 5, 9, 4, 0, 2], [3, 5, 9, 4, 0, 2], [4, 0, 2]], "left": [[1, 7, 6, 8, 3, 5, 9, 4], [], [1, 7, 6, 8, 3, 5, 9, 4, 0], [1, 7, 6, 8], [1, 7, 6, 8, 3, 5, 9], [1, 7, 6, 8, 3], [1, 7], [1], [1, 7, 6], [1, 7, 6, 8, 3, 5]]}}

The target object idx is 9.

When I run it in loop (with other scenes), I will encounter a stack overflow:

 File "**/research/synthesis_specs/src/evaluation/clevr_caption/logic/core/goal.py", line 58, in <listcomp>
    base, *rest = [arg(state) for arg in self._arguments]
  File "**/research/synthesis_specs/src/evaluation/clevr_caption/logic/core/goal.py", line 36, in __call__
    return self.execute(state)
  File "**/research/synthesis_specs/src/evaluation/clevr_caption/logic/core/goal.py", line 73, in execute
    return Stream.unit(state.unify(self._left, self._right))
  File "**/research/synthesis_specs/src/evaluation/clevr_caption/logic/core/state.py", line 48, in unify
    result = self.clone()
  File "**/research/synthesis_specs/src/evaluation/clevr_caption/logic/core/state.py", line 18, in clone
    return deepcopy(self)
  File "**/anaconda3/lib/python3.7/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "**/anaconda3/lib/python3.7/copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)

When I run it seperately, it takes a long time to run. I killed it after around 20 minutes.

Can you help me look into this issue? Since this error occurs at the state we want to find a third clause.

Thank you in advance!

moqingyan commented 4 years ago

It runs to an end finally. I will find a better example.

moqingyan commented 4 years ago

Scene:

"objects": [{"size": "small", "color": "brown", "shape": "cylinder", "material": "metal"}, {"size": "small", "color": "brown", "shape": "cylinder", "material": "metal"}, {"size": "large", "color": "purple", "shape": "sphere", "material": "rubber"}, {"size": "large", "color": "gray", "shape": "cube", "material": "rubber"}, {"size": "small", "color": "blue", "shape": "cube", "material": "metal"}, {"size": "small", "color": "brown", "shape": "cylinder", "material": "metal"}, {"size": "small", "color": "gray", "shape": "cube", "material": "rubber"}], "relationships": {"right": [[5, 2, 1, 4], [4], [1, 4], [0, 5, 2, 1, 4], [], [2, 1, 4], [3, 0, 5, 2, 1, 4]], "behind": [[6, 3], [6, 3, 0, 5, 2], [6, 3, 0, 5], [6], [6, 3, 0, 5, 2, 1], [6, 3, 0], []], "front": [[5, 2, 1, 4], [4], [1, 4], [0, 5, 2, 1, 4], [], [2, 1, 4], [3, 0, 5, 2, 1, 4]], "left": [[6, 3], [6, 3, 0, 5, 2], [6, 3, 0, 5], [6], [6, 3, 0, 5, 2, 1], [6, 3, 0], []]}}

target object idx: 0

This also leads to the stack overflow error in logic core.