Introducción al aprendizaje profundo con PyTorch
Jasmin Ludolf
Senior Data Science Content Developer, DataCamp
# Create network with three linear layers model = nn.Sequential(nn.Linear(n_features, 8),nn.Linear(8, 4), nn.Linear(4, n_classes))
nn.Sequential() son capas ocultas# Create network with three linear layers
model = nn.Sequential(
nn.Linear(n_features, 8), # n_features represents number of input features
nn.Linear(8, 4),
nn.Linear(4, n_classes) # n_classes represents the number of output classes
)
nn.Sequential() son capas ocultasn_features y n_classes están definidos por el conjunto de datos



# Create network with three linear layers
model = nn.Sequential(
nn.Linear(10, 18),
nn.Linear(18, 20),
nn.Linear(20, 5)
)
# Create network with three linear layers
model = nn.Sequential(
nn.Linear(10, 18), # Takes 10 features and outputs 18
nn.Linear(18, 20),
nn.Linear(20, 5)
)
# Create network with three linear layers
model = nn.Sequential(
nn.Linear(10, 18),
nn.Linear(18, 20), # Takes 18 and outputs 20
nn.Linear(20, 5)
)
# Create network with three linear layers
model = nn.Sequential(
nn.Linear(10, 18),
nn.Linear(18, 20),
nn.Linear(20, 5) # Takes 20 and outputs 5
)
$$

$$
$$

$$
$$

$$
$$

$$

$$

$$
Cálculo manual de parámetros:
$$

$$
Cálculo manual de parámetros:
$$

$$
Cálculo manual de parámetros:
$$

$$
Cálculo manual de parámetros:
$$

$$
Utilizando PyTorch:
.numel(): devuelve el número de elementos del tensortotal = 0
for parameter in model.parameters():
total += parameter.numel()
print(total)
46

Introducción al aprendizaje profundo con PyTorch