I want to create a NN with a given number of layers.
For that, I want to loop through the variable hidden layers
and initialize the weights for each of the layers. However, I need different names in order to store the different weights, so I want to name the W
variables with a parameter inside them. Initializing as many as the parameter says
So, if: hidden_layers = 2
.
My variables to initialize are: w1, w2
If hidden_layers = 4
Then I would like to have: w1, w2, w3, w4
I want to initialize the variables with a for loop:
for i in range (hidden_layers):
W + str(i) = tf.Variable(tf.initializers.GlorotUniform()(shape=[input_shape,code_length]),name='W1') #This is wrong!
Could someone help? Thanks!