CodeReclaimers / neat-python

Python implementation of the NEAT neuroevolution algorithm
BSD 3-Clause "New" or "Revised" License
1.41k stars 490 forks source link

How can we use neat-python for classification? #185

Open oushu1zhangxiangxuan1 opened 4 years ago

oushu1zhangxiangxuan1 commented 4 years ago

Is there any ready-made loss or activation functions (like softmax and cross-entropy)for categorical labels in neat-python?

Or some best practices for classification task?

It seems now I could only do one-hot and cross-entropy in my own?

avolution commented 4 years ago
import numpy as np
from neat.math_util import softmax

...

net_output = net.activate(input_vector)
softmax_result = softmax(net_output)
class_output = np.argmax(((softmax_result / np.max(softmax_result)) == 1).astype(int))