0Pricing
Deep Learning Academy · Ders

Logitlerle İkili Çapraz Entropi

İki sınıflı problemler için kararlı kayıp.

Logitlerle İkili Çapraz Entropi, CoddyKit'te ücretsiz bir Deep Learning Academy dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Deep Learning Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Deep Learning Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Two Classes, One Decision

When your model answers a yes or no question like spam or not spam, you reach for binary cross-entropy, the loss built for two-class problems. ✅

From Score to Probability

A model first outputs a raw score called a logit. The sigmoid function squashes that logit into a probability between 0 and 1.

import torch
prob = torch.sigmoid(logit)

What Cross-Entropy Rewards

Cross-entropy gives a small loss when the predicted probability is close to the true label, and a large loss when it is confidently wrong.

Confident and Wrong Hurts

Predicting 0.99 when the true label is 0 produces a huge loss. Cross-entropy punishes confident mistakes far more than uncertain ones.

The Naive Loss Choice

You could apply sigmoid yourself, then use nn.BCELoss on the probabilities. It works, but there is a safer way for real training.

import torch.nn as nn
loss_fn = nn.BCELoss()
loss = loss_fn(prob, target)

Feed Logits, Not Probabilities

The preferred loss is BCEWithLogitsLoss. It takes raw logits directly and applies the sigmoid internally for you.

import torch.nn as nn
loss_fn = nn.BCEWithLogitsLoss()
loss = loss_fn(logit, target)

Why Combine the Steps

Fusing sigmoid and the loss uses the log-sum-exp trick, which avoids overflow and gives stable gradients even at extreme logits.

Skip the Extra Sigmoid

Because BCEWithLogitsLoss applies sigmoid itself, your model's last layer should output raw logits with no sigmoid attached.

Targets Are 0 or 1

Pass float targets of 0.0 or 1.0 with the same shape as your logits. A mismatched shape is the classic BCE bug to watch for.

target = torch.tensor([1.0, 0.0, 1.0])

Sigmoid Only at Inference

During training the loss handles the squashing. To read a probability for a prediction, apply sigmoid to the logit at inference time.

Tilt the Balance with pos_weight

If positives are rare, the pos_weight argument scales up their contribution so the model stops ignoring the minority class.

Quick Check

You are doing binary classification and want numerical stability. What should you feed the loss?

Recap: Stable Yes or No

For two-class tasks you feed raw logits to BCEWithLogitsLoss, which squashes and scores in one stable step. Save sigmoid for reading probabilities later. 👍

Sıkça Sorulan Sorular

“Logitlerle İkili Çapraz Entropi” dersi ücretsiz mi?

Evet — “Logitlerle İkili Çapraz Entropi” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Deep Learning Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Deep Learning Academy kursu toplamda 4 dersten oluşur.

“Logitlerle İkili Çapraz Entropi” dersinde ne öğreneceğim?

İki sınıflı problemler için kararlı kayıp. Deep Learning Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Deep Learning Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Deep Learning Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.

“Logitlerle İkili Çapraz Entropi” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Deep Learning Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Deep Learning Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Regresyon için MSE ve MAE
  2. Logitlerle İkili Çapraz Entropi
  3. Çok Sınıflı Problemler için Çapraz Entropi
  4. Dengesiz Veriler için Sınıf Ağırlıkları
← Deep Learning Academy Sayfasına Dön