Einführung in Deep Learning mit 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()
sind verdeckte Schichten# 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()
sind versteckte Ebenenn_features
und n_classes
sind durch den Datensatz definiert# 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
)
$$
$$
$$
$$
$$
$$
$$
$$
$$
$$
Manuelle Parameterberechnung:
$$
$$
Manuelle Parameterberechnung:
$$
$$
Manuelle Parameterberechnung:
$$
$$
Manuelle Parameterberechnung:
$$
$$
Mit PyTorch:
.numel()
gibt die Anzahl der Elemente des Tensors zurück.total = 0
for parameter in model.parameters():
total += parameter.numel()
print(total)
46
Einführung in Deep Learning mit PyTorch