Skip to content

Commit 076ab64

Browse files
committed
minor changes
1 parent 45dfe01 commit 076ab64

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

assignment1/config.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ validation=./DATA/validate_small.csv
77
# layers is a comma-separated list of integers telling us how many nodes in each
88
# hidden layer. Special case: If the value is only one element in the list, and
99
# its value is 0, you should generate a net without a hidden layer
10-
layers = 400, 400, 400, 100
10+
layers = 24, 24
1111

1212
# activations is a comma-separated list of key-words. It will have as many
1313
# elements as there are elements in the layers-list. Each keyword is a
1414
# non-linearity function, and legal values are relu, linear, and tanh.
15-
activations = relu, relu, relu, relu
15+
activations = relu, relu
1616

1717
# loss_type chooses between L2 loss (for regression) and
1818
# cross_entropy (for classification).
@@ -26,6 +26,6 @@ learning_rate=5.e-4
2626
no_epochs=500
2727

2828
# What L2-regularization to use to avoid overfitting.
29-
L2_regularization=5.E-5
29+
L2_regularization=0
3030

3131

assignment1/network.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def get_l2_regularization(self, derivate=False, weights=False):
5656
return l2_derivate_matrix
5757
else:
5858
all_weights_squared = np.sum(np.sum(layer.w ** 2) for layer in self.layers)
59-
all_biases_squared = np.sum(np.sum(layer.b ** 2) for layer in self.layers)
60-
return self.regularization_factor * (all_weights_squared)
59+
# all_biases_squared = np.sum(np.sum(layer.b ** 2) for layer in self.layers)
60+
return self.regularization_factor * all_weights_squared
6161

6262
def get_loss(self, layer, target_y, estimate_y, derivate=False):
6363
if layer.loss == "L2":
@@ -74,9 +74,9 @@ def get_loss(self, layer, target_y, estimate_y, derivate=False):
7474
print("Lol")
7575
if derivate:
7676
derivate = estimate_y - target_y
77-
derivate[(derivate >= -0.000001) & (derivate <= 0.000001)] = 0
78-
derivate[(derivate >= 0.999)] = 1
79-
derivate[(derivate <= -0.999)] = -1
77+
# derivate[(derivate >= -0.000001) & (derivate <= 0.000001)] = 0
78+
# derivate[(derivate >= 0.999)] = 1
79+
# derivate[(derivate <= -0.999)] = -1
8080
return derivate
8181
return loss
8282

@@ -127,8 +127,7 @@ def back_propagation(self, activations, target_y, zs, learning_rate=0.0001):
127127
layer.w = layer.w - (learning_rate * np.array(last_error).dot(np.transpose(
128128
activations[layer_i])) + self.regularization_factor * layer.w)
129129

130-
layer.b = layer.b - (learning_rate * last_error + self.regularization_factor *
131-
layer.b)
130+
layer.b = layer.b - (learning_rate * last_error)
132131
else:
133132
layer.b = layer.b - (learning_rate * last_error)
134133
layer.w = layer.w - (learning_rate * np.array(last_error).dot(np.transpose(

0 commit comments

Comments
 (0)