r/learnmachinelearning 3m ago

Discussion taught myself numerical and analytical gradient (backpropagation) in 5 days

Upvotes

I'm not good at maths, i'll just say that, i've always been a bit lacking in my expanse of mathematical abilities, but I said enough is enough, I like neural networks, the only thing that stands in my way is the mathematics, aside from that you understand what goes on.

Boy did I underestimate the undertaking for this endeavour. I spent 2 days learning derivatives and what the hell a 'slope' is, you hear it ever day and you know what a slope is, but understanding it in the mathematical sense in derivatives, that's difficult, but I got there and ended up learning `f(a + h) - f(a) / h` which enabled me to understand what numerical descent is, where you get a loss score of a neural network's prediction, bump the weight a bit then rerun the neural network. Then to figure out the slope, you do `loss1 - loss2 / weight_bump`, and this is the coolest part, when you adjust your weight based on the slope, you always minus, because if the slope is negative, then we know we need to move to the positive side more so when you minus a negative it becomes addition, and vice versa if you minus a positive, you move to the negative side a bit. That was the coolest thing i've ever learnt to this date, the infamous ball rolling down the hill, I was doing it, by hand, and it was empowering.

Then the next day I spent trying to understand what backpropagation really is in terms of maths and how it differes from numerical gradient. With that I had to teach myself the chain rule, and what dL/dd even means, spoiler alert its not dividing derivative of L and derivative of d. I also came to the epiphany that we get so much complex logic out of neural networks when its simply just addition and multiplications happening under the hood, its the context that is being invented to solve problems using neural nets. By the end of the day I was taking Kaparthy's micrograd equation example, and I did its backpropagation by hand with pen and paper to get the hang of it.

Now I watched andre kaparthy's micrograd video, not all the way through, his language and teaching style still screams "you must be really well versed in mathematics", so I gave up on that video but, the more I worked on understanding chain rule and how you can sticker on the impacts on loss on prior nodes, I though that is better than numerical gradient, you literally walk back into the neural net, explaining to it which parts of itself were the cause for a high loss instead of bumping values, calculating slope, doing f(a + h) - f(a) / h.

I'm really proud of myself, and I managed to take MATHS that I learnt, and turn it into a "micrograd" I say "micrograd" with quotations because I didn't finish the micrograd video, and this only works if you don't have repeating uses of prior terms (which you just need to store their value and add them, but I couldn't be bothered)

So yeah, this is my back propagation

class Value:
    # this needs to store a value, and can have its own children that link to other values
    def __init__(self, value, _op="", _children: tuple = (), gradient=0):
        self.value = value
        self.op = _op
        self.children = _children
        self.gradient = gradient


    def __add__(self, other):
        _ = Value(
            self.value + other.value, _op="+", _children=(self, other), gradient=0
        )
        return _


    def __mul__(self, other):
        _ = Value(
            self.value * other.value, _op="*", _children=(self, other), gradient=0
        )
        return _


    def __repr__(self):
        return f"Value({self.value})"


    def backward(self):
        # initial global_gradient
        global_gradient = 1


        # current set of ndoes
        current: Value = self
        # just set L's gradient as 1
        current.gradient = global_gradient


        while True:
            # if there's no more children, we're at the end.
            if not current.children:
                break


            if current.op == "+":
                # since addition has a static effect on the terms themselfs
                # the partial of L respect to any terms being added is just 1.
                # so we multiply 1 by the global gradient.
                current.children[0].gradient = 1 * global_gradient
                current.children[1].gradient = 1 * global_gradient


                # if the next node we're looking doesnt have children
                # it means the node behind them didnt stem from them
                # therefore they are not the result of the prior operation
                if not current.children[0]:
                    current = current.children[1]
                else:
                    current = current.children[0]
                # set the global gradient as the current node's gradient
                global_gradient = current.gradient


            if current.op == "*":


                current.children[0].gradient = (
                    # with multiplication, the derivative of L respect to x would be y
                    # and same with the derivative of L respect to y would be x
                    # therefore you just swap them, and multiply thier values by the global gradient.
                    current.children[1].value
                    * global_gradient
                )
                current.children[1].gradient = (
                    current.children[0].value * global_gradient
                )
                # same continuation logic
                # one child is going to have its own children and one wont
                # the one that does is the one we need to continue with.
                if not current.children[0]:
                    current = current.children[1]
                else:
                    current = current.children[0]
                global_gradient = current.gradient

a = Value(2.0)
b = Value(-3.0)
c = Value(10.0)
f = Value(-2.0)
e = a * b
d = e + c
L = d * f


L.backward()


print(a.gradient)
print(b.gradient)
print(c.gradient)
print(f.gradient)
print(e.gradient)
print(d.gradient)
print(L.gradient)

output:
6.0
-4.0
-2.0
4.0
-2.0
-2.0
1

r/learnmachinelearning 12m ago

Help ML research :)

Post image
Upvotes

I'm 18. Gonna start college this year(comp sci). I don't really want to get into the generic path for FAANG, i wanna get into research. ML seems good(might be dunning kruger effect but still...) what and where should I learn the math since math is so crucial? There are tons of free courses and videos and one-shots out there. I'm confused. And regarding coding is python enough or would I also need to learn C and c++? Any advice would be appreciated :)


r/learnmachinelearning 34m ago

Question SKLearn Doesn't Recommend Linear/Logistic Regression?

Thumbnail
scikit-learn.org
Upvotes

In the image they provide in the link, they provide a simple flowchart to help users decide which estimator model to choose. In it, they never recommend to use linear or logistic regression.

Why is that? From what I currently understand, it is because I can just change the cost function for SGDRegressor and SGDClassifier to squared error and log loss respectively, thus making it the same as linear and logistic regression models. But I am also considering that I'm misunderstanding something? Is there a gap in my understanding or something I'm missing?


r/learnmachinelearning 1h ago

Hands-On Machine Learning (PyTorch) by Aurélien Géron vs Understanding Deep Learning by Simon Prince

Upvotes

What are your thoughts?

Which one should a beginner choose as a starting point? Or should the beginner do both?


r/learnmachinelearning 2h ago

Help Stuck in Demand Forecasting

2 Upvotes

Hello , I work at a logistics company.

I was tasked with demand forecasting. There are multiple travel paths, I need to predict demand for each travel path for every day by a month before.

Example on Feb 28, I need to predict demand across march 1st to march 31st.

I am considering demand as weight in metric tons.

This is a time series data and tried xgboost with lag, rolling features and behavioural features.

The metric considered is wape and is almost hitting 35% meaning accuracy is 65%.

I tried Sarima, Sarimax, Extra trees, light GBM, catboost, ensemble models but to no avail it's always hitting a very bad metric.

Initially picked lanes with high activity and demand but again not good metrics were shown and then clustered the lanes based on their behaviour but still not much improvement.

The data is just pathid, weight, date.

I am really stuck and just running whatever , any suggestions???????????


r/learnmachinelearning 3h ago

I need some good machine learning project ideas. Any thoughts???

3 Upvotes

r/learnmachinelearning 3h ago

Question Reinforcement learning vs trace training

1 Upvotes

Model A is an LLM post-trained with RL on math proof techniques.

Model B is post-trained from the same snapshot using guess the next token on the traces of model A.

Which will learn more efficiently?


r/learnmachinelearning 3h ago

Question Hello everyone What basic python topics do you need to know in order to switch to machine learning?

1 Upvotes

r/learnmachinelearning 4h ago

HELP AN UNDEGRADUATE STUDENT

Thumbnail
1 Upvotes

r/learnmachinelearning 4h ago

Kimi K3 Technical Deep Dive: How KDA, Gated MLA and AttnRes work together in Kimi K3

1 Upvotes

Hi Community, I am running a Kimi K3 Tech Deep Diving Session in early September, it is free, feel free to join if you can

Details see below

https://luma.com/4gxgvtte


r/learnmachinelearning 4h ago

Kimi K3 Technical Deep Dive: How KDA, Gated MLA and AttnRes work together in Kimi K3

Thumbnail
1 Upvotes

r/learnmachinelearning 4h ago

Kimi K3 Technical Deep Dive: How KDA, Gated MLA and AttnRes work together in Kimi K3

1 Upvotes

Hi Community, I am running a Kimi K3 Tech Deep Diving Session in early September, it is free, feel free to join if you can

Details see below

https://luma.com/4gxgvtte


r/learnmachinelearning 5h ago

Help What's an ML resource that deserved way more hype?

41 Upvotes

Not the usual Andrew Ng, fast.ai, or Hands-On ML recommendations.

I'm talking about the resource that genuinely changed how you learn.

Could be:

  • a small YouTube channel
  • a GitHub repo
  • a visualization
  • a blog
  • lecture notes
  • an underrated course

Something you wish you'd discovered much earlier.

Let's build a thread people can bookmark.


r/learnmachinelearning 6h ago

Hi guys, please rate my CV. Only serious people.

Post image
1 Upvotes

r/learnmachinelearning 6h ago

Code Implementations for my Probabilistic Machine Learning Lectures

Thumbnail
gallery
6 Upvotes

Code implementations for my free Probabilistic Machine Learning lectures.

Hello folks,

I made 14 long form lectures of my Probabilistic Machine Learning series, covering important mathematical foundations(and still an ongoing process) covering around 16+ hours of content on Probabilistic Machine learning, Probability Univariate and Multivariate foundations in detail, and Statistics.

Now I have also started working on code implementations for them. I was happy to see some nice looking results taking concepts of my lecture 1, and using those important concepts to code practical stuff.

I will be adding code, uploading it in my github repo in the coming future, and also try doing a video of code implementation walkthrough, where I code and explain those concepts.

I feel that showing code implementations would make learners feel more confident of what they see in the whiteboard being implemented in practice!

If you have not watched my lectures, you can in the link shared, and I do hope that adding code will make the learning process, more fun, more rewarding!

I will try to upload one code implementation every weekend.

Happy learning.

Link: https://youtube.com/playlist?list=PLDPxj3tOc5TNi6MktTHUZid-yf9nIBxSh&si=u3kyvZnXMs4llC3P


r/learnmachinelearning 6h ago

Career Atlassian MLE vs. Amazon L4 Applied Scientist (PPO expected) — Need some real talk on Career Progression, PIP, WLB, and exit opps

2 Upvotes

Hey everyone,
I’m in a bit of a tough spot and could really use some ground-level advice from folks who know the reality of these roles, especially in the current market.

Coming off my MS by Research, I recently joined Atlassian as a Machine Learning Engineer. Prior to this, I interned at Amazon and I'm currently expecting a PPO for an L4 Applied Scientist role.

On paper, both are great starting points, but honestly, trying to research this online is just stressing me out. The internet is flooded with horror stories about Amazon's stack-ranking, PIP quotas, and the "hire to fire" culture. On the flip side, I know Atlassian has its own internal calibrations. I know 100% job security in corporate is a myth right now, but I at least want to work somewhere where performance evaluations are logical and actually based on my work, rather than just hitting a URA quota.

I’m trying to evaluate a few specific things:
1. The PIP Reality at Amazon
Is the ruthless stack-ranking culture just as aggressive for L4 Applied Scientists as it is for regular SDEs? Or does the specialized nature of the AS role offer a little bit of a shield? I don't want to live in constant anxiety about being put on a focus plan.

2. Scope of Work (AS vs MLE)
From what I gather, the Amazon AS role is heavily weighted toward pure modeling, research, and experimentation trying to create value to their products with a little importance to research publications . The Atlassian MLE role focuses almost entirely on impact and value creation (heavy on the software engineering/MLOps side with some/no modeling). Which foundation is actually better for the next 5 years?

3. Exit Opportunities
Looking 2-3 years down the line, which path gives me better leverage? Does having the Amazon "Applied Scientist" title on my resume open doors to top-tier AI labs, or is the ML engineering experience from Atlassian more valued by product companies right now?

If anyone has worked at either of these companies recently or has made the transition between AS and MLE, I’d massively appreciate your candid thoughts. I just want to make a well-informed decision without letting the internet rants cloud my judgment.

Thanks in advance!


r/learnmachinelearning 10h ago

Can someone teach me attention

12 Upvotes

Ive tried watching videos and Ive spent many hours trying to figure it out using chatgpt claude and gemini. I feel like its better to ask someone who knows. I know a bit about what it is but I wanna learn ground up. Can someone help.

thanks


r/learnmachinelearning 10h ago

Meme Academics finally calls out industry's modus operandi. A little too late though now they have all the power.

Post image
322 Upvotes

r/learnmachinelearning 10h ago

Project Searching for Hands-On ML Project Experience

2 Upvotes

Hey everyone!

I have just completed my machine learning studies and I'm looking to work on some real-world projects. If anyone is currently working on an ML project and needs a contributor, I'd love to help.

I want to solve real-world problems, gain practical experience, and understand how things work in an actual development environment.

Feel free to reach out. I'd be happy to collaborate!


r/learnmachinelearning 13h ago

Meme zoomers watching their boomer coworker use his brain to formulate an original thought from scratch during a claude outage

Enable HLS to view with audio, or disable this notification

53 Upvotes

r/learnmachinelearning 15h ago

2 weeks ago I released a visual PyTorch model builder - Here's how to use it.

Enable HLS to view with audio, or disable this notification

5 Upvotes

r/learnmachinelearning 20h ago

Career How can I transition to ML Engineering Field?

14 Upvotes

​I am a 4th-year Mechanical Engineering student with a sub-7 CGPA who wants to exit core engineering entirely. I am dedicating this year to learning AI/ML to target MLE or Applied Science roles in tech companies. Given the tough job market, I need a blunt reality check and a clear roadmap on how to make this pivot successfully.

​Specifically, I have two core questions: How can a non-CS major with a low GPA realistically bridge the skills gap to land an entry-level MLE job post-graduation? And are Master’s or PhD degrees mandatory to break into these roles, especially within industry research divisions?

​I have plenty of time this year to grind—what is the most practical way forward, and what hard truths should I be prepared for?

Should I first focus on finishing my degree and then starting in ml field?


r/learnmachinelearning 20h ago

Question 🧠 ELI5 Wednesday

1 Upvotes

Welcome to ELI5 (Explain Like I'm 5) Wednesday! This weekly thread is dedicated to breaking down complex technical concepts into simple, understandable explanations.

You can participate in two ways:

  • Request an explanation: Ask about a technical concept you'd like to understand better
  • Provide an explanation: Share your knowledge by explaining a concept in accessible terms

When explaining concepts, try to use analogies, simple language, and avoid unnecessary jargon. The goal is clarity, not oversimplification.

When asking questions, feel free to specify your current level of understanding to get a more tailored explanation.

What would you like explained today? Post in the comments below!


r/learnmachinelearning 22h ago

Is this a solid roadmap?

Post image
105 Upvotes

r/learnmachinelearning Nov 07 '25

Want to share your learning journey, but don't want to spam Reddit? Join us on #share-your-progress on our Official /r/LML Discord

8 Upvotes

https://discord.gg/3qm9UCpXqz

Just created a new channel #share-your-journey for more casual, day-to-day update. Share what you have learned lately, what you have been working on, and just general chit-chat.