Skip to content

Commit

Permalink
modify
Browse files Browse the repository at this point in the history
  • Loading branch information
bowen-xu committed Nov 15, 2023
1 parent 27b3794 commit 756ed51
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 26 deletions.
9 changes: 3 additions & 6 deletions cpp/src/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ std::set<pNode> &Group::activate(size_t i_column)
/* 更新node的状态 */
for (auto &node : nodes)
{
if (node->ts_update == this->ts - 1)
node->roll_state();
else if (node->ts_update < this->ts - 1)
node->reset_state();
node->ts_update = ts;
node->update(this->ts);
}
/* 激活结点。首先判断是否存在预激活的结点,如果存在,则激活那些结点;否则激活所有结点。 */
bool anticipated = std::any_of(
Expand Down Expand Up @@ -272,7 +268,7 @@ void Group::learn(size_t i_column)

if (nodes_selected.size() == 0)
{
/* 如果没有任何激活的结点,则从现有的激活结点中,选取一个value最大的结点进行学习。 */
/* 如果没有任何预测后激活的结点,则从现有的激活结点中,选取一个value最大的结点进行学习。 */
double value_max = 0.0;
for (pNode &post_node : nodes)
for (auto &[ante_node, ante_link] : post_node->ante_links->links)
Expand Down Expand Up @@ -332,6 +328,7 @@ void Group::learn(size_t i_column)
}
}
}

for (auto &post_node : this->buffer2)
{
// auto n = post_node->ante_links->links.size();
Expand Down
18 changes: 0 additions & 18 deletions utils/Profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,6 @@ def __init__(self, window=100) -> None:
self.cnt_total = 0
self.cnt_correct = 0
self.pred_correct = np.full(window, False)

# def observe1(self, pred, compare):
# ''''''
# if self.cnt_total < len(self.pred_correct):
# self.cnt_total += 1
# if len(pred) > 0:
# pred = sorted(pred, key=lambda x: -x[1].e)
# result = chr(compare+65) == Interpreter.get(Column, pred[0][0]._column._id)
# else:
# result = False
# if result:
# self.cnt_correct += 1
# if self.pred_correct[0]:
# self.cnt_correct -= 1
# self.pred_correct[:-1] = self.pred_correct[1:]
# self.pred_correct[-1] = result
# acc = self.cnt_correct / self.cnt_total
# return acc

def observe(self, pred: set, compare):
''''''
Expand Down
2 changes: 0 additions & 2 deletions utils/draw_group.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
try:
from ..narsese import Term, Statement, Truth
from ..SequentialGroup import Group, Column, Node, Link, Bundle
except ValueError as e:
from narsese import Term, Statement, Truth
from SequentialGroup import Group, Column, Node, Link, Bundle
from typing import List
import networkx as nx
Expand Down

0 comments on commit 756ed51

Please sign in to comment.