0Pricing
Deep Learning Academy · Lección

Congele el backbone y entrene el head

Reutilice características aprendidas con poco coste

Congele el backbone y entrene el head es una lección gratuita de Deep Learning Academy en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Deep Learning Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Deep Learning Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

Borrow a Smart Brain

Why train from zero? A model already trained on millions of images has learned useful features. Transfer learning reuses that knowledge for your task. 🧠

Backbone vs Head

A pretrained model has two parts: the backbone that extracts general features, and the head that makes the final prediction for its original task.

The Plan

The simplest recipe: freeze the backbone so it stays as is, then swap in a fresh head and train only that part on your own labels.

Load a Pretrained Model

Start with a model that already carries good weights. torchvision hands you popular architectures with one call.

from torchvision import models
model = models.resnet18(weights='DEFAULT')

Freezing Means No Gradients

To freeze a layer you set requires_grad to False. PyTorch then skips computing gradients for it, so its weights never change.

for p in model.parameters():
    p.requires_grad = False

Why Freeze at All?

Freezing the backbone keeps its hard-won features intact and means far fewer weights to update. That makes training faster and works with little data.

Swap the Head

The old head predicts the wrong classes. Replace it with a fresh Linear layer sized for your number of classes.

import torch.nn as nn
model.fc = nn.Linear(512, 3)

The New Head Is Trainable

A brand-new layer starts with requires_grad set to True automatically. So only your head will learn while the frozen backbone watches.

Optimize Only the Head

Pass just the head's parameters to your optimizer. Updating only these few weights is what makes this approach so cheap.

opt = torch.optim.Adam(model.fc.parameters(), lr=1e-3)

The Backbone Becomes an Extractor

With its weights frozen, the backbone simply turns each image into a rich feature vector. Your head learns to read those features.

When This Shines

Freeze-and-train-head is ideal with a small dataset or limited compute. You get strong results in minutes instead of days.

Quick Check

You froze the backbone and replaced the head. Which weights actually update during training?

Recap

You learned to borrow a pretrained backbone, freeze it, attach a fresh head, and train just that head. Fast, cheap, and great with small data. 🎯

Preguntas frecuentes

¿La lección «Congele el backbone y entrene el head» es gratis?

Sí — el texto completo de «Congele el backbone y entrene el head» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Deep Learning Academy, actualiza a CoddyKit PRO. El curso de Deep Learning Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Congele el backbone y entrene el head»?

Reutilice características aprendidas con poco coste Practicas Deep Learning Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Deep Learning Academy?

No se requiere experiencia previa. Deep Learning Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.

¿Cuánto tiempo toma la lección «Congele el backbone y entrene el head»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Deep Learning Academy?

Sí. Cada lección de Deep Learning Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Congele el backbone y entrene el head
  2. Haga fine-tuning con una tasa de aprendizaje menor
  3. Tasas discriminativas por capa
  4. Haga fine-tuning de un modelo de Hugging Face
← Volver a Deep Learning Academy