Close Menu
    Trending
    • 3D Printer Breaks Kickstarter Record, Raises Over $46M
    • People are using AI to ‘sit’ with them while they trip on psychedelics
    • Reinforcement Learning in the Age of Modern AI | by @pramodchandrayan | Jul, 2025
    • How This Man Grew His Beverage Side Hustle From $1k a Month to 7 Figures
    • Finding the right tool for the job: Visual Search for 1 Million+ Products | by Elliot Ford | Kingfisher-Technology | Jul, 2025
    • How Smart Entrepreneurs Turn Mid-Year Tax Reviews Into Long-Term Financial Wins
    • Become a Better Data Scientist with These Prompt Engineering Tips and Tricks
    • Meanwhile in Europe: How We Learned to Stop Worrying and Love the AI Angst | by Andreas Maier | Jul, 2025
    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

    Reinforcement Learning in the Age of Modern AI | by @pramodchandrayan | Jul, 2025

    July 1, 2025
    Machine Learning

    Finding the right tool for the job: Visual Search for 1 Million+ Products | by Elliot Ford | Kingfisher-Technology | Jul, 2025

    July 1, 2025
    Machine Learning

    Meanwhile in Europe: How We Learned to Stop Worrying and Love the AI Angst | by Andreas Maier | Jul, 2025

    July 1, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    3D Printer Breaks Kickstarter Record, Raises Over $46M

    July 1, 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

    The Brutal Truth About Breaking Into Data Science & AI/ML (And What Actually Works) | by Vikhil Indra Potluri | May, 2025

    May 10, 2025

    NumExpr: The “Faster than Numpy” Library Most Data Scientists Have Never Used

    April 28, 2025

    Risking Trump’s Ire, E.U. Accuses Apple and Google of Unfair Practices

    March 19, 2025
    Our Picks

    3D Printer Breaks Kickstarter Record, Raises Over $46M

    July 1, 2025

    People are using AI to ‘sit’ with them while they trip on psychedelics

    July 1, 2025

    Reinforcement Learning in the Age of Modern AI | by @pramodchandrayan | Jul, 2025

    July 1, 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.