➡️ Machine Learning from Scratch, part 46: training is NP-hard.
MachineLearningToGo
Visit on TikTok31K followers
16,900 views #machinelearning #ai #claude
➡️ Machine Learning from Scratch, part 46: training is NP-hard. P is the class of problems a computer can solve quickly, where the time grows only like a power of the input size. NP is the class of problems where a proposed answer can be checked quickly, like a filled sudoku. Every problem in P is also in NP, and the open question is whether every problem that is quick to check is also quick to solve. P versus NP is one of seven Millennium Prize Problems, and most researchers believe the answer is no. In 1988, Avrim Blum and Ronald Rivest proved that finding weights that fit all training examples is NP-complete, even for a network of three neurons that switch on or off. Gradient descent never searches for the perfect weights: it follows the slope downhill and stops once the weights are good enough, and real training data are usually much friendlier than the hardest cases of the proof. The code (nphard.py, 16 lines of numpy) fits a network with three tanh neurons and 7 weights to 40 noisy points. A grid of 10 values per weight means 10 million combinations; the best one has an error of 0.01481, and the search took about 25 CPU seconds on our laptop, ten times longer for each extra weight. Gradient descent with step 0.1 beats the best combination after 17 steps and reaches 0.0100 after 1000 steps, a third lower. Honest notes: the proof is about threshold neurons and exact fits, our test uses tanh neurons and a mean square error, and the timings depend on the machine. In our test, gradient descent gets the slope by nudging each weight a tiny bit. #machinelearning #ai #claude #pvsnp #gradientdescent
Comments
Comments from the original post on TikTok
No comments yet
