forked from HBPNeurorobotics/hbpprak_2018_throwing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_weights.py
22 lines (16 loc) · 795 Bytes
/
set_weights.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import numpy as np
@nrp.MapVariable("weights", initial_value = None, scope = nrp.GLOBAL)
@nrp.MapVariable("topology", initial_value = None, scope = nrp.GLOBAL)
@nrp.MapVariable("bias", initial_value = None, scope = nrp.GLOBAL)
def set_weights (t, weights,topology, bias):
if weights.value is None and bias.value is None:
clientLogger.info('Setting network')
top = [6,100,20,6]
in_wieghts = {}
in_bias = {}
for index in range(1,len(top)):
in_wieghts['layer{}'.format(index)]=np.random.uniform(-1,1,(top[index-1], top[index]))
in_bias['layer{}'.format(index)]=np.random.uniform(-1,1,(1,top[index]))
weights.value = in_wieghts
topology.value = top
bias.value = in_bias