Visualization convolution intermediate layer TensorFlow

Visualization TensorFlow intermediate layer image convolution method

The main function

tf.summary.image(name, tensor, max_outputs=3, collections=None, family=None)

参数解析
name:A name for the generated node. Will also serve as a series name in TensorBoard.

tensor:A 4-D uint8 or float32 Tensor of shape [batch_size, height, width, channels] where channels is 1, 3, or 4.

  • 1: tensor is interpreted as Grayscale.
  • 3: tensor is interpreted as RGB.
  • 4: tensor is interpreted as RGBA.
    Images having the same input channel number tensor. For floating-point input value as a time normalized in [0, 255], uint8 unchanged. op using two different standardized algorithms:

If the input values ​​are positive, then readjust them, the maximum value of 255.

If any input value is negative, the movement value, the input value of 127. Then 0.0 readjust them, so that the minimum value is 0, or a maximum value of 255.

max_outputs: Max number of batch elements to generate images for.

The core idea of
the features of FIG considered (channel) multiple images. First, according to the current dimensions of the feature maps which splits the number of channels, and then split after by-feature map visualization.

Sample Code

    with tf.variable_scope('layer1-conv1'):
        conv1_weights=tf.get_variable('weights',[5,5,1,6],initializer=tf.truncated_normal_initializer(stddev=0.1))
        conv1_biases=tf.get_variable('biases',[6],initializer=tf.constant_initializer(0.1))
        conv1=tf.nn.conv2d(input_tensor,conv1_weights,strides=[1,1,1,1],padding='VALID')
        bias1=tf.nn.bias_add(conv1,conv1_biases)
        relu1=tf.nn.relu(bias1)

        split = tf.split(relu1, relu1.shape[-1], axis=3) 
        for i in range(relu1.shape[-1]):
            tf.summary.image("layer1-conv1-channel_"+str(i),split[i],1)

Actual operation

Visualization TensorBoard last inst_depth layer (batch, height, width, (K + 1))
Visualization of the intermediate layer

Additional: ubuntu can not access the local area network to share files resolved under win10

The reason: win10 default samba1.0 not open shared file service
program:
1. Go to "Control Panel", go to "Programs and Features"

2. Select "Enable or disable Windows features"

3. Make sure that the function list, select the "SMB1.0 / CIFS file sharing support", and then determine the installation, restart your computer to take effect.

Guess you like

Origin www.cnblogs.com/Caiyi-Xu/p/12513217.html