I created a custom initializer with Keras. Part of the code is:
def my_init(shape):
P = tf.get_variable("P", shape=shape, initializer = tf.contrib.layers.xavier_initializer())
return P
model = Sequential()
model.add(Conv2D(32, kernel_size=(5, 5),strides=(1, 1), padding='same', input_shape = input_shape, kernel_initializer = my_init))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, kernel_size=(1, 1) , strides=(1, 1) , padding='same' , kernel_initializer = my_init))
When "my_init" initializer is called for the second time in the convolution layer it throws this error:
Variable P already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
It is not allowing to reuse the variable P. Is there any way to create a new variable in each call?