Skip to content

Commit 85ba968

Browse files
committed
update weights
1 parent 8f3d497 commit 85ba968

File tree

4 files changed

+19
-26
lines changed

4 files changed

+19
-26
lines changed

hidden_layer.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ def calcOutputs(self):
2929
#
3030
# set Weight Updated
3131
#
32-
# def setWeightsUpdated(self , updatedWeights):
33-
# #TODO: testing...
34-
# x = len(self.getWeights())
35-
# updatedWeightsTemp = updatedWeights[:x]
36-
# # if updatedWeights is numpy delete is false
37-
# del updatedWeights[:x]
38-
# for n in self.neurons:
39-
# n.updatedWeights(updatedWeightsTemp)
32+
def setWeightsUpdated(self , updatedWeights):
33+
#TODO: testing...
34+
x = len(self.neurons[0].getNumOfWeights())
35+
for i in range(0 , len(self.neurons)):
36+
updatedWeightsTemp = updatedWeights[i*x:(i+1)*x]
37+
self.neurons[i].updatedWeights(updatedWeightsTemp)
4038
#
4139
#
4240
#

input_layer.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@ def getOutput(self):
4545
#
4646
# set weight updated
4747
#
48-
# def setWeightsUpdated(self , updatedWeights):
49-
# #TODO: testing...
50-
# x = len(self.getWeights())
51-
# updatedWeightsTemp = updatedWeights[:x]
52-
# # if updatedWeights is numpy delete is false
53-
# updatedWeights = np.array([:x])
54-
# for n in self.neurons:
55-
# n.updatedWeights(updatedWeightsTemp)
56-
#
48+
def setWeightsUpdated(self , updatedWeights):
49+
#TODO: testing...
50+
x = len(self.neurons[0].getNumOfWeights())
51+
for i in range(0 , len(self.neurons)):
52+
updatedWeightsTemp = updatedWeights[i*x:(i+1)*x]
53+
self.neurons[i].updatedWeights(updatedWeightsTemp)
54+
5755
#
5856
#
5957

neuron.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def calc_output(self):
2828
return self.output
2929

3030
def updateWeights(self, updatedWeights):
31-
#TODO: delete one elements
3231
self.weights = np.array([])
3332
np.copyto(self.weights , updatedWeights)
3433
print("weightsupdated" , self.weights)

output_layer.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ def calcOutputs(self):
2727
#
2828
# set Weight updated
2929
#
30-
# def setWeightsUpdated(self , updatedWeights):
31-
# #TODO: testing...
32-
# x = len(self.getWeights())
33-
# updatedWeightsTemp = updatedWeights[:x]
34-
# # if updatedWeights is numpy delete is false
35-
# del updatedWeights[:x]
36-
# for n in self.neurons:
37-
# n.updatedWeights(updatedWeightsTemp)
30+
def setWeightsUpdated(self , updatedWeights):
31+
#TODO: testing...
32+
x = len(self.neurons[0].getNumOfWeights())
33+
for i in range(0 , len(self.neurons)):
34+
updatedWeightsTemp = updatedWeights[i*x:(i+1)*x]
35+
self.neurons[i].updatedWeights(updatedWeightsTemp)
3836
#
3937
#
4038
#

0 commit comments

Comments
 (0)