def predict(self, input_sdr=None):
"""
Argument inputs is ndarray of indexes into the input space.
Returns probability of each catagory in output space.
"""
self.input_sdr.assign(input_sdr)
pdf = self.stats[self.input_sdr.flat_index]
if True:
# Combine multiple probabilities into single pdf. Product, not
# summation, to combine probabilities of independant events. The
# problem with this is if a few unexpected bits turn on it
# mutliplies the result by zero, and the test dataset is going to
# have unexpected things in it.
return np.product(pdf, axis=0, keepdims=False)
else:
# Use summation B/C it works well.
return np.sum(pdf, axis=0, keepdims=False)
评论列表
文章目录