I tried to create weights for a CNN automatically using a for loop and a dictionary in python. The problem is that the size of W1 has to be equal to the size of W2 ... But I can not find a way of doing it. The size shape_1 is the output of nodes and shape_2 is the input of nodes. So basically the nodes of W1 have to go as an input to W2.
def initialize_parameters(NumberOfParameters):
parameters={}
for i in range( 1 ,NumberOfParameters):
shape_1 = 25
shape_2 = 12288
parameters['W' + str(i)] = tf.get_variable("W"+str(i),[shape_1, shape_2],initializer=tf.contrib.layers.xavier_initializer(seed=1))
parameters['b' + str(i)] = tf.get_variable("b"+str(i),[shape_1, 1],initializer=tf.zeros_initializer)
shape_2 = shape_1
shape_1 = shape_1 // 2
return parameters
#Quiero que mi output sea este:
#W1 : [25, 12288]
#b1 : [25, 1]
#W2 : [12, 25!]
#b2 : [12, 1]
#W3 : [6, 12]
#b3 : [6, 1]
# En vez de esto
#W1 : [25, 12288]
#b1 : [25, 1]
#W2 : [25, 12288]
#b2 : [25, 1]
#W3 : [25, 12288]
#b3 : [25, 1]
Sorry for the indentation, I do not control very well StackOverflow Thanks !!