Skip to content

Crash on Cartpole interaction phase #59

@ntoxeg

Description

@ntoxeg

The Cartpole example crashes when trying to run the learning agent (epochs = 5 in the notebook).

ic| msg: 'Learning phase started. (1/5)'
[/usr/local/lib/python3.10/dist-packages/scipy/stats/_continuous_distns.py:608](): RuntimeWarning: divide by zero encountered in _beta_pdf
  return _boost._beta_pdf(x, a, b)
ic| msg: 'Interaction phase started. (1/5)'
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/workspace/01_cartpole.ipynb Cell 21' in <module>
     [17]()[ log_msg(agent_log, f"Interaction phase started. ({i + 1}/{epochs})")
     ]()[18]()[ for j in range(epoch_len):
---> ]()[19]()[     done = agent.control_cycle()
     ]()[20]()[     wrapped_env.render()  # uncomment to see the rendered env
     ]()[21]()[     time.sleep(0.01)

File /workspace/rocca/agents/core.py:1587, in OpencogAgent.control_cycle(self)
   ]()[1584]()[ agent_log.debug("cogscms [count={}]:\n{}".format(len(cogscms), cogscms))
   ]()[1586]()[ # Deduce the action distribution
-> ]()[1587]()[ mxmdl = self.deduce(cogscms)
   ]()[1588]()[ agent_log.debug("mxmdl:\n{}".format(mxmdl_to_str(mxmdl)))
   ]()[1590]()[ # Select the next action

File /workspace/rocca/agents/core.py:1491, in OpencogAgent.deduce(self, cogscms)
   ]()[1456]()[ # For each cognitive schematic estimate the probability of its
   ]()[1457]()[ # context to be true and multiply it by the truth value of the
   ]()[1458]()[ # cognitive schematic, then calculate its weight based on
   (...)
   ]()[1486]()[ # result, as they allegedly exert an unknown influence (via
   ]()[1487]()[ # their invalid parts).
   ]()[1488]()[ ctx_tv = lambda cogscm: get_context_actual_truth(
   ]()[1489]()[     self.atomspace, cogscm, self.cycle_count
   ]()[1490]()[ )
-> ]()[1491]()[ valid_cogscms = [cogscm for cogscm in cogscms if 0.9 < ctx_tv(cogscm).mean]
   ]()[1492]()[ agent_log.fine(
   ]()[1493]()[     "valid_cogscms [count={}]:\n{}".format(len(valid_cogscms), valid_cogscms)
   ]()[1494]()[ )
   ]()[1496]()[ # Size of the complete data set, including all observations
   ]()[1497]()[ # used to build the models.
   ]()[1498]()[ #
   ]()[1499]()[ # Needs to be set before calling self.weight

File /workspace/rocca/agents/core.py:1491, in <listcomp>(.0)
   ]()[1456]()[ # For each cognitive schematic estimate the probability of its
   ]()[1457]()[ # context to be true and multiply it by the truth value of the
   ]()[1458]()[ # cognitive schematic, then calculate its weight based on
   (...)
   ]()[1486]()[ # result, as they allegedly exert an unknown influence (via
   ]()[1487]()[ # their invalid parts).
   ]()[1488]()[ ctx_tv = lambda cogscm: get_context_actual_truth(
   ]()[1489]()[     self.atomspace, cogscm, self.cycle_count
   ]()[1490]()[ )
-> ]()[1491]()[ valid_cogscms = [cogscm for cogscm in cogscms if 0.9 < ctx_tv(cogscm).mean]
   ]()[1492]()[ agent_log.fine(
   ]()[1493]()[     "valid_cogscms [count={}]:\n{}".format(len(valid_cogscms), valid_cogscms)
   ]()[1494]()[ )
   ]()[1496]()[ # Size of the complete data set, including all observations
   ]()[1497]()[ # used to build the models.
   ]()[1498]()[ #
   ]()[1499]()[ # Needs to be set before calling self.weight

File /workspace/rocca/agents/core.py:1488, in OpencogAgent.deduce.<locals>.<lambda>(cogscm)
   ]()[1454]()[ agent_log.fine("deduce(cogscms={})".format(cogscms))
   ]()[1456]()[ # For each cognitive schematic estimate the probability of its
   ]()[1457]()[ # context to be true and multiply it by the truth value of the
   ]()[1458]()[ # cognitive schematic, then calculate its weight based on
   (...)
   ]()[1486]()[ # result, as they allegedly exert an unknown influence (via
   ]()[1487]()[ # their invalid parts).
-> ]()[1488]()[ ctx_tv = lambda cogscm: get_context_actual_truth(
   ]()[1489]()[     self.atomspace, cogscm, self.cycle_count
   ]()[1490]()[ )
   ]()[1491]()[ valid_cogscms = [cogscm for cogscm in cogscms if 0.9 < ctx_tv(cogscm).mean]
   ]()[1492]()[ agent_log.fine(
   ]()[1493]()[     "valid_cogscms [count={}]:\n{}".format(len(valid_cogscms), valid_cogscms)
   ]()[1494]()[ )

File /workspace/rocca/agents/utils.py:832, in get_context_actual_truth(atomspace, cogscm, i)
    ]()[825]()[ body = AndLink(
    ]()[826]()[     PresentLink(*stamped_present_clauses),
    ]()[827]()[     IsClosedLink(*stamped_present_clauses),
    ]()[828]()[     IsTrueLink(*stamped_present_clauses),
    ]()[829]()[     *virtual_clauses
    ]()[830]()[ )
    ]()[831]()[ query = SatisfactionLink(vardecl, body)
--> ]()[832]()[ tv = execute_atom(atomspace, query)
    ]()[833]()[ return tv

File execute.pyx:14, in opencog.execute.execute_atom()

RuntimeError: BUG! Still have ungrounded clauses!! (/home/opencog/atomspace/opencog/query/NextSearchMixin.cc:154)]()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions