Close Menu
    Trending
    • EdgeConneX and Lambda to Build AI Factory Infrastructure in Chicago and Atlanta
    • French streamer’s death ‘not traumatic’, autopsy finds
    • Why Every Entrepreneur Needs an Exit Mindset from Day One
    • Is Reading Dead? Why Gen Z Prefers AI Voices Over Books
    • Beyond KYC: AI-Powered Insurance Onboarding Acceleration
    • Designing a Machine Learning System: Part Five | by Mehrshad Asadi | Aug, 2025
    • Innovations in Artificial Intelligence That Are Changing Agriculture
    • Hundreds of thousands of Grok chats exposed in Google results
    AIBS News
    • Home
    • Artificial Intelligence
    • Machine Learning
    • AI Technology
    • Data Science
    • More
      • Technology
      • Business
    AIBS News
    Home»Machine Learning»A primer on using PyTorch Optimizers | by Nikolaus Correll | Jan, 2025
    Machine Learning

    A primer on using PyTorch Optimizers | by Nikolaus Correll | Jan, 2025

    Team_AIBS NewsBy Team_AIBS NewsJanuary 5, 2025No Comments1 Min Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Learn to use PyTorch optimizers, perceive what occurs throughout optimizer.step() and optimizer.zero_grad()

    PyTorch is a numerical library with an “autograd” characteristic, that it’s it’s going to maintain observe of any computational path and might numerically compute its spinoff. This makes PyTorch a first-rate device for optimization. Contemplate this easy instance to seek out the minimal of the perform y=(x-3)²:

    import torch

    # Initialize x
    x = torch.tensor(0.0, requires_grad=True) # Begin at x=0, requires_grad to compute gradients
    learning_rate = 0.4

    for step in vary(10):
    # Compute y = (x - 3)^2
    y = (x - 3)**2

    # Compute the gradient
    y.backward() # Populates x.grad with the gradient of y w.r.t x

    # Replace x manually
    with torch.no_grad(): # Quickly disable gradient monitoring
    x -= learning_rate * x.grad # Gradient descent step
    x.grad.zero_() # Clear gradients for the following step

    print(f"Step {step+1}: x = {x.merchandise()}, y = {y.merchandise()}")

    Step 1: x = 2.4000000953674316, y = 9.0
    Step 2: x = 2.880000114440918, y = 0.3599998950958252
    Step 3: x = 2.9760000705718994, y = 0.01439997274428606
    Step 4: x = 2.9951999187469482, y = 0.0005759965861216187
    Step 5: x = 2.999039888381958, y = 2.3040780433802865e-05
    Step 6: x = 2.9998080730438232, y = 9.218143190992123e-07
    Step 7: x = 2.9999616146087646, y = 3.6835956507275114e-08
    Step 8: x = 2.9999923706054688, y = 1.4734382602910046e-09
    Step 9: x =…



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleDisney’s former head of innovation shares secrets for boosting your creativity
    Next Article Awesome Plotly with Code Series (Part 7): Cropping the y-axis in Bar Charts | by Jose Parreño | Jan, 2025
    Team_AIBS News
    • Website

    Related Posts

    Machine Learning

    Designing a Machine Learning System: Part Five | by Mehrshad Asadi | Aug, 2025

    August 21, 2025
    Machine Learning

    Mastering Fine-Tuning Foundation Models in Amazon Bedrock: A Comprehensive Guide for Developers and IT Professionals | by Nishant Gupta | Aug, 2025

    August 21, 2025
    Machine Learning

    “How to Build an Additional Income Stream from Your Phone in 21 Days — A Plan You Can Copy” | by Zaczynam Od Zera | Aug, 2025

    August 21, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    EdgeConneX and Lambda to Build AI Factory Infrastructure in Chicago and Atlanta

    August 21, 2025

    I Tried Buying a Car Through Amazon: Here Are the Pros, Cons

    December 10, 2024

    Amazon and eBay to pay ‘fair share’ for e-waste recycling

    December 10, 2024

    Artificial Intelligence Concerns & Predictions For 2025

    December 10, 2024

    Barbara Corcoran: Entrepreneurs Must ‘Embrace Change’

    December 10, 2024
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    Most Popular

    Introducing Server-Sent Events in Python | Towards Data Science

    August 5, 2025

    Jargons of NLP. NLP (and especially LLMs) are full of… | by Dhananjaikrishnakumar | Apr, 2025

    April 21, 2025

    How to Build Resilience and Drive Growth in Turbulent Times

    July 29, 2025
    Our Picks

    EdgeConneX and Lambda to Build AI Factory Infrastructure in Chicago and Atlanta

    August 21, 2025

    French streamer’s death ‘not traumatic’, autopsy finds

    August 21, 2025

    Why Every Entrepreneur Needs an Exit Mindset from Day One

    August 21, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2024 Aibsnews.comAll Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.