可视化Tensorflow中的卷积层

时间:2019-04-08 04:12:41

标签: python tensorflow deep-learning conv-neural-network imshow

我有用于卷积神经网络的代码。

convnet = input_data(shape=[None, IMG_SIZE, IMG_SIZE, IMAGE_CHANNELS], name='input')
convnet1 = conv_2d(convnet, FIRST_NUM_CHANNEL, FILTER_SIZE, activation='relu')
convnet1 = max_pool_2d(convnet1, FILTER_SIZE)
convnet2 = conv_2d(convnet1, FIRST_NUM_CHANNEL*2, FILTER_SIZE, activation='relu')
convnet2 = max_pool_2d(convnet2, FILTER_SIZE)
convnet_final = fully_connected(convnet2, FIRST_NUM_CHANNEL*16, activation='relu')
convnet_final = dropout(convnet_final, 0.8)
convnet_final = fully_connected(convnet_final, NUM_OUTPUT, activation='softmax')
convnet_final = regression(convnet_final, optimizer='adam', learning_rate=LR, loss='categorical_crossentropy', name='targets')
model = tflearn.DNN(convnet_final, tensorboard_dir='log')

如何可视化convnet1或convnet2?我已经有了以下代码:

img = convnet1[0, :, :,  0]

但是 img 的数据类型为 Tensor(“ MaxPool2D / MaxPool:0”,shape =(?, 52,52,32),dtype = float32) 。我仍然需要将其转换为numpy数组之类的东西,或者可以在 imshow()或任何其他图像显示中传递的东西。我还可以通过使用 model.session 获得运行该模型的会话。

0 个答案:

没有答案