File tree Expand file tree Collapse file tree 6 files changed +6
-2
lines changed Expand file tree Collapse file tree 6 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ print(model)
118
118
# Compute and print parameter count
119
119
n_params = get_parameter_count(model)
120
120
print (f " Model has { n_params} trainable parameters " )
121
+ # Linear layers have (in_features + 1) * out_features parameters
121
122
assert n_params == 2
122
123
```
123
124
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ def test_linear_regression(show_plots=False):
86
86
# Compute and print parameter count
87
87
n_params = get_parameter_count (model )
88
88
print (f"Model has { n_params } trainable parameters" )
89
+ # Linear layers have (in_features + 1) * out_features parameters
89
90
assert n_params == 2
90
91
91
92
# Use Mean Squared Error loss
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ print(model)
129
129
# Compute and print parameter count
130
130
n_params = get_parameter_count(model)
131
131
print (f " Model has { n_params} trainable parameters " )
132
- # Number of entries is 2 (x- and y-coordinates) + 1 (bias)
132
+ # Linear layers have (in_features + 1) * out_features parameters
133
133
assert n_params == 3 * output_dim
134
134
```
135
135
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def test_logistic_regression(show_plots=False):
68
68
# Compute and print parameter count
69
69
n_params = get_parameter_count (model )
70
70
print (f"Model has { n_params } trainable parameters" )
71
- # Number of entries is 2 (x- and y-coordinates) + 1 (bias)
71
+ # Linear layers have (in_features + 1) * out_features parameters
72
72
assert n_params == 3 * output_dim
73
73
74
74
# Use cross-entropy loss function.
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ print(model)
139
139
# Compute and print parameter count
140
140
n_params = get_parameter_count(model)
141
141
print (f " Model has { n_params} trainable parameters " )
142
+ # Linear layers have (in_features + 1) * out_features parameters.
142
143
# Hidden layer has (2 + 1) * hidden_layer_dim parameters.
143
144
# Output layer has (hidden_layer_dim + 1) * 1 parameters
144
145
assert n_params == 3 * hidden_layer_dim + hidden_layer_dim + 1
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ def test_multilayer_perceptron(show_plots=False):
78
78
# Compute and print parameter count
79
79
n_params = get_parameter_count (model )
80
80
print (f"Model has { n_params } trainable parameters" )
81
+ # Linear layers have (in_features + 1) * out_features parameters.
81
82
# Hidden layer has (2 + 1) * hidden_layer_dim parameters.
82
83
# Output layer has (hidden_layer_dim + 1) * 1 parameters
83
84
assert n_params == 3 * hidden_layer_dim + hidden_layer_dim + 1
You can’t perform that action at this time.
0 commit comments