I have multiple strings defined as the following:
"Conv2D(filters=8, kernel_size=(2, 2), strides=(1,1), padding='valid', data_format='channels_last', activation='relu', use_bias=True, kernel_initializer='zeros', bias_initializer='zeros', kernel_regularizer=regularizers.l1_l2(l1=0.01,l2=0.01), bias_regularizer=regularizers.l1_l2(l1=0.01,l2=0.01), activity_regularizer=regularizers.l1_l2(l1=0.01,l2=0.01), kernel_constraint=max_norm(2.), bias_constraint=max_norm(2.), input_shape=(28,28,1))"
I want to extract the value of kernel_size
in the string for which I tried the following thing:
match = re.search(i+'(.+?), (.+?) ',value)
where i = 'kernel_size'
and and value is the string defined above.
When I run this, I get
<regex.Match object; span=(18, 38), match='kernel_size=(2, 2), '>
I also run the following command to get the value using the above match:
filters = match.group(1).split("=")[1].strip()
but I get this:
kernel_size (2
How can I get something like this:
kernel_size (2,2)