copyright nepes corp. all rights reserved
The following is an example of learning and retrieves affected neurons after learning. If the
queryAffected is set to 0, the information of affected neurons will not be returned. If the
queryAffected is set to 1, it will return list of affected neurons. but the processing time will be
increased by more than 2 times.
#
# learn vector (10, 10, 10) with category 10
#
learn_req = nmengine.LearnReq()
vector = [10 for i in range(3)]
# Send max length to avoid gabages in neuron memory.
# If you set the size with actual vector length (< NEURON_MEMORY),
# the remaining value will be filled with garbege value
learn_req.size = nmengine.NEURON_MEMORY
learn_req.vector[:len(vector)] = vector
learn_req.category = 10
# This is optional field for retrieving affected neuron infromation
# If you set the value to 1, it takes more time to learn.
learn_req.query_affected = 1
print('learn req(cat, affected flag, len, vector)', learn_req.category, \
learn_req.query_affected, learn_req.size, tuple(learn_req.vector))
# Fro the learning result,
# refer to 'The result code for learning' in constants.py
print('train a vector to network, result:', nmengine.learn(target, learn_req), \
'status:', learn_req.status)
# Prints affected neurons
for i in range(learn_req.affected_count):
neuron = learn_req.affected_neurons[i]
print('A (nid, cat, aif) :', neuron.nid, neuron.cat, neuron.aif)