3
$\begingroup$

I recently finished coding my own MLP neural network in Python. To make my code easier to read, I separated the MLP, into classes; the network class, the layers class and the neuron class, where the neuron class would do all the calculations such as the activation and calculating the error signal. Each neuron also contained an array of the weights.

To verify the results of my MLP, I tried the sklearn-MLPClassifier with the same dataset, and found that sklearn was actually much faster to train than with my code.

Would my code be faster if I rewrite it with matrices? Whats the right way to code a NN and how can I get my performance to be comaparable to that of sklearn ?

$\endgroup$

1 Answer 1

2
$\begingroup$

Would my code be faster if I rewrite it with matrices?

Without seeing the code it's impossible to know, but very likely. Also, I would never model single neurons. Too much overhead without any use. Model layers instead.

how can I get my performance to be comaparable to that of sklearn

Sklearn is open source. Read the code: https://github.com/scikit-learn/scikit-learn/blob/7389dba/sklearn/neural_network/multilayer_perceptron.py#L682

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.