I am using tf.layers.conv2d
in TensorFlow V1.0 to do convolution.
An example is as follows :
conv1 = tf.layers.conv2d(batch_images, filters=96,
kernel_size=7,
strides=2,
activation=tf.nn.relu,
kernel_initializer=tf.contrib.layers.xavier_initializer_conv2d(uniform=False),
bias_initializer=tf.contrib.layers.xavier_initializer(uniform=False),
kernel_regularizer=tf.nn.l2_loss,
bias_regularizer=tf.nn.l2_loss,
name='conv1')
I then try to collect the filter weights as follows :-
l1weights = tf.get_collection(tf.GraphKeys.WEIGHTS, 'conv1')
However although the network is getting trained, I get []
on evaluating l1weights
inside a session.
How do I extract the filter weights and visualize them using tf.summary.image
?
I managed to get the weights using the following
conv1 = tf.layers.conv2d(
inputs=input_layer,
filters=32,
kernel_size=[5, 5],
padding="same",
activation=tf.nn.relu, name='conv1')
kernel = tf.get_collection(tf.GraphKeys.VARIABLES, 'conv1/kernel')[0]
bias = tf.get_collection(tf.GraphKeys.VARIABLES, 'conv1/bias')[0]
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With