• bitcoinBitcoin(BTC)$79,554.00-1.49%
  • ethereumEthereum(ETH)$2,305.74-2.32%
  • tetherTether(USDT)$1.00-0.01%
  • binancecoinBNB(BNB)$736.85-0.76%
  • rippleXRP(XRP)$1.29-1.17%
  • usd-coinUSDC(USDC)$1.000.02%
  • solanaSolana(SOL)$100.83-1.37%
  • tronTRON(TRX)$0.3300830.25%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.06-0.69%
  • zcashZcash(ZEC)$1,199.61-1.44%
  • HyperliquidHyperliquid(HYPE)$75.91-0.83%
  • dogecoinDogecoin(DOGE)$0.076470-1.60%
  • moneroMonero(XMR)$588.94-4.13%
  • USDSUSDS(USDS)$1.00-0.01%
  • whitebitWhiteBIT Coin(WBT)$76.62-1.63%
  • chainlinkChainlink(LINK)$11.37-1.83%
  • leo-tokenLEO Token(LEO)$9.040.00%
  • cardanoCardano(ADA)$0.202044-2.89%
  • RainRain(RAIN)$0.0084703.30%
  • stellarStellar(XLM)$0.167560-2.31%
  • nearNEAR Protocol(NEAR)$4.490.57%
  • bitcoin-cashBitcoin Cash(BCH)$277.830.25%
  • daiDai(DAI)$1.00-0.01%
  • Ethena USDeEthena USDe(USDE)$1.000.00%
  • litecoinLitecoin(LTC)$56.51-0.93%
  • uniswapUniswap(UNI)$6.870.51%
  • CantonCanton(CC)$0.100558-0.07%
  • USD1USD1(USD1)$1.00-0.01%
  • avalanche-2Avalanche(AVAX)$8.83-1.47%
  • suiSui(SUI)$0.91-2.43%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.24-0.60%
  • hedera-hashgraphHedera(HBAR)$0.076800-1.42%
  • tether-goldTether Gold(XAUT)$3,990.35-0.03%
  • Global DollarGlobal Dollar(USDG)$1.000.01%
  • paypal-usdPayPal USD(PYUSD)$1.00-0.01%
  • BittensorBittensor(TAO)$251.02-0.01%
  • shiba-inuShiba Inu(SHIB)$0.000005-1.98%
  • quant-networkQuant(QNT)$190.164.95%
  • crypto-com-chainCronos(CRO)$0.053959-2.86%
  • EthenaEthena(ENA)$0.2032384.33%
  • BitwayBitway(BTW)$1.64-6.48%
  • Ripple USDRipple USD(RLUSD)$1.000.00%
  • Circle USYCCircle USYC(USYC)$1.140.00%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.150.17%
  • okbOKB(OKB)$107.80-0.76%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • MemeCoreMemeCore(M)$0.942.39%
  • aaveAave(AAVE)$134.77-2.19%
  • OndoOndo(ONDO)$0.404643-1.18%
  • Pump.funPump.fun(PUMP)$0.004179-3.02%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

Stochastic Gradient Descent (SGD’s) Frequency Bias and How Adam Fixes It 

May 18, 2026
in AI & Technology
Reading Time: 3 mins read
A A
Stochastic Gradient Descent (SGD’s) Frequency Bias and How Adam Fixes It 
ShareShareShareShareShare
BG   = "#fafaf8"
DARK = "#1a1a1a"

# Color ramp: blue for common tokens, red for rare
TOKEN_COLORS = ["#1a5276", "#2471a3", "#5dade2", "#e67e22", "#c0392b", "#7d2a2a"]

steps = np.arange(N_STEPS)

fig = plt.figure(figsize=(16, 11), facecolor=BG)
fig.suptitle(
    "SGD vs. Adam on Rare Tokens -- Frequency Bias and Variance Normalization",
    fontsize=14, fontweight="bold", color=DARK, y=0.99
)

gs = gridspec.GridSpec(2, 3, figure=fig, hspace=0.45, wspace=0.35)

# ── 1. SGD weight trajectories ────────────────────────────────
ax1 = fig.add_subplot(gs[0, :2])
ax1.set_facecolor(BG)
ax1.axhline(1.0, color=DARK, lw=1, ls="--", alpha=0.3, label="True weight = 1.0")

for i, (token, color) in enumerate(zip(TOKENS, TOKEN_COLORS)):
    ax1.plot(steps, sgd_history[:, i], color=color, lw=1.8,
             label=f"{token} (freq={FREQ[i]:.3f})")

ax1.set_title("SGD -- Weight Trajectories\nRare tokens barely move from zero", fontsize=11, color=DARK)
ax1.set_xlabel("Training Step", fontsize=9)
ax1.set_ylabel("Learned Weight", fontsize=9)
ax1.legend(fontsize=8, loc="right")
ax1.set_ylim(-0.3, 1.6)
ax1.spines[["top", "right"]].set_visible(False)

# Annotate failure zone
ax1.annotate(
    "Rare tokens stuck\nnear zero",
    xy=(N_STEPS * 0.95, sgd_history[-1, 5]),
    xytext=(N_STEPS * 0.65, -0.15),
    fontsize=8.5, color="#c0392b",
    arrowprops=dict(arrowstyle="->", color="#c0392b", lw=1.2),
    bbox=dict(boxstyle="round,pad=0.3", facecolor="#fff0f0", edgecolor="#c0392b", alpha=0.85)
)

# ── 2. Final weight error bar chart ───────────────────────────
ax2 = fig.add_subplot(gs[0, 2])
ax2.set_facecolor(BG)

x      = np.arange(6)
w_sgd  = sgd_final
w_adam = adam_final
width  = 0.35

bars_sgd  = ax2.bar(x - width/2, np.abs(w_sgd  - TRUE_W), width, color="#c0392b", alpha=0.85, label="SGD error")
bars_adam = ax2.bar(x + width/2, np.abs(w_adam - TRUE_W), width, color="#2980b9", alpha=0.85, label="Adam error")

ax2.set_xticks(x)
ax2.set_xticklabels([t[:8] for t in TOKENS], rotation=30, ha="right", fontsize=8)
ax2.set_ylabel("|learned w − true w|", fontsize=9)
ax2.set_title("Final Weight Error\n(lower = better)", fontsize=11, color=DARK)
ax2.legend(fontsize=8)
ax2.spines[["top", "right"]].set_visible(False)

# ── 3. Adam weight trajectories ───────────────────────────────
ax3 = fig.add_subplot(gs[1, :2])
ax3.set_facecolor(BG)
ax3.axhline(1.0, color=DARK, lw=1, ls="--", alpha=0.3, label="True weight = 1.0")

for i, (token, color) in enumerate(zip(TOKENS, TOKEN_COLORS)):
    ax3.plot(steps, adam_history[:, i], color=color, lw=1.8,
             label=f"{token} (freq={FREQ[i]:.3f})")

ax3.set_title("Adam -- Weight Trajectories\nRare tokens converge via variance normalization", fontsize=11, color=DARK)
ax3.set_xlabel("Training Step", fontsize=9)
ax3.set_ylabel("Learned Weight", fontsize=9)
ax3.legend(fontsize=8, loc="right")
ax3.set_ylim(-0.3, 1.6)
ax3.spines[["top", "right"]].set_visible(False)

ax3.annotate(
    "Rare tokens converge\ndespite sparse gradients",
    xy=(N_STEPS * 0.95, adam_history[-1, 5]),
    xytext=(N_STEPS * 0.60, 0.3),
    fontsize=8.5, color="#27ae60",
    arrowprops=dict(arrowstyle="->", color="#27ae60", lw=1.2),
    bbox=dict(boxstyle="round,pad=0.3", facecolor="#f0fff4", edgecolor="#27ae60", alpha=0.85)
)

# ── 4. Effective LR vs frequency ─────────────────────────────
ax4 = fig.add_subplot(gs[1, 2])
ax4.set_facecolor(BG)

ax4.scatter(FREQ, effective_lr, c=TOKEN_COLORS, s=120, zorder=5, edgecolors="white", lw=1.5)
for i, token in enumerate(TOKENS):
    ax4.annotate(token, (FREQ[i], effective_lr[i]),
                 textcoords="offset points", xytext=(6, 4), fontsize=7.5, color=TOKEN_COLORS[i])

ax4.axhline(LR, color=DARK, lw=1, ls="--", alpha=0.4)
ax4.text(0.5, LR * 1.05, f"Nominal LR = {LR}", fontsize=8, color=DARK, alpha=0.6)

ax4.set_xscale("log")
ax4.set_yscale("log")
ax4.set_xlabel("Token Frequency (log scale)", fontsize=9)
ax4.set_ylabel("Adam Effective LR  lr/√v̂  (log scale)", fontsize=9)
ax4.set_title("Adam's Automatic Equalizer\nRare tokens get amplified LR", fontsize=11, color=DARK)
ax4.spines[["top", "right"]].set_visible(False)

plt.savefig("sgd_vs_adam.png", dpi=150, bbox_inches="tight", facecolor=BG)
plt.show()

Credit: Source link

YOU MAY ALSO LIKE

Which Screenless Fitness Tracker Is Better For You?

Why Google Chrome Is Always Using So Much RAM

ShareTweetSendSharePin

Related Posts

Which Screenless Fitness Tracker Is Better For You?
AI & Technology

Which Screenless Fitness Tracker Is Better For You?

October 26, 2026
Why Google Chrome Is Always Using So Much RAM
AI & Technology

Why Google Chrome Is Always Using So Much RAM

October 25, 2026
Nanbeige Releases Nanbeige4.3-33B, a 33B Open Agentic Coding Model
AI & Technology

Nanbeige Releases Nanbeige4.3-33B, a 33B Open Agentic Coding Model

October 25, 2026
What Does The Bell Icon Mean On Your CarPlay Screen?
AI & Technology

What Does The Bell Icon Mean On Your CarPlay Screen?

October 25, 2026
Next Post
TrumpRx expands to offer over 600 generic drugs, partners with Mark Cuban

TrumpRx expands to offer over 600 generic drugs, partners with Mark Cuban

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
We Might Finally Know What’s Written On That Mysterious Plaque In Super Mario 64

We Might Finally Know What’s Written On That Mysterious Plaque In Super Mario 64

October 19, 2026
Google illegally tore down 250K trees for Finland data center, infuriating locals: report

Google illegally tore down 250K trees for Finland data center, infuriating locals: report

October 24, 2026
US envoy arrives in Russia ahead of meeting with Putin as Zelensky says intelligence sharing 'works now' – BBC

US envoy arrives in Russia ahead of meeting with Putin as Zelensky says intelligence sharing 'works now' – BBC

October 21, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!