[英]how can i extract images from the last decoder layer “logits” after training my neural network?
i'm training a neural network model using tensorflow , for image segmentation , and i want to be able to extract the images after training, from the final logits layer 我正在使用tensorflow训练神经网络模型以进行图像分割,并且我希望能够在训练后从最终的Logit层提取图像
here is the decoder part of my model 这是我模型的解码器部分
DECODER 解码器
upsampling layer 1 : 上采样层1:
upsample1 = tf.image.resize_images(pool5, size=(200, 200), method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
Deconvolutional layer 1 :
deconv1 = tf.layers.conv2d_transpose(inputs=upsample1, filters=512, kernel_size=(3, 3),strides=(1, 1), padding='same',
activation=tf.nn.relu)
deconv1bis = tf.layers.conv2d_transpose(inputs=deconv1, filters=512, kernel_size=(3, 3),strides=(1, 1), padding='same',
activation=tf.nn.relu)
deconv1bisbis = tf.layers.conv2d_transpose(inputs=deconv1bis, filters=512, kernel_size=(3, 3),strides=(1, 1), padding='same',
activation=tf.nn.relu)
upsampling layer 2 : 上采样层2:
upsample2 = tf.image.resize_images(deconv1bisbis, size=(200, 200), method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
Deconvolutional layer 2 : 反卷积层2:
deconv2 = tf.layers.conv2d_transpose(inputs=upsample2, filters=512,strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
deconv2bis = tf.layers.conv2d_transpose(inputs=deconv2, filters=512,strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
deconv2bisbis = tf.layers.conv2d_transpose(inputs=deconv2bis, filters=512, strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
upsampling layer 3 : 上采样层3:
upsample3 = tf.image.resize_images(deconv2bisbis, size=(200, 200), method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
Deconvolutional layer 3 : 反卷积层3:
deconv3 = tf.layers.conv2d_transpose(inputs=upsample3, filters=256,strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
deconv3bis = tf.layers.conv2d_transpose(inputs=deconv3, filters=256,strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
deconv3bisbis = tf.layers.conv2d_transpose(inputs=deconv3bis, filters=512,strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
upsampling layer 4 : 上采样层4:
upsample4 = tf.image.resize_images(deconv3bisbis, size=(200, 200), method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
Deconvolutional layer 4 : 反卷积层4:
deconv4 = tf.layers.conv2d_transpose(inputs=upsample4, filters=128,strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
deconv4bis = tf.layers.conv2d_transpose(inputs=deconv4, filters=128,strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
upsampling layer 5 : 上采样层5:
upsample5 = tf.image.resize_images(deconv4bis, size=(200, 200), method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
Deconvolutional layer 5 : 反卷积层5:
deconv5 = tf.layers.conv2d_transpose(inputs=upsample5, filters=64,strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
deconv5bis = tf.layers.conv2d_transpose(inputs=deconv5, filters=64,strides=(1, 1), kernel_size=(3, 3), padding='same',
activation=tf.nn.relu)
Logits Layer Logits层
logits = tf.layers.dense(inputs=deconv5bis, units=1, activation=tf.nn.relu)
any one have an idea how i can do that ? 有人知道我该怎么做吗?
I guess what you mean by : 我猜你的意思是:
I want to be able to extract the images after training, from the final logits layer
我希望能够在训练后从最终的Logits层提取图像
Well, actually this doesn't work this way. 好吧,实际上这行不通。 But don't worry, I guess you meant that you want to see how you can see the segmentation or the masks on the images after you finish the training of your neural network.
但是不用担心,我想您的意思是您想看完神经网络训练后如何看到图像上的分割或蒙版。
Here we are talking about the prediction part after the training is done. 在这里,我们谈论的是训练完成后的预测部分。
Once you are done, you can take any image you want and apply this model to output the segmentation results on it. 完成后,您可以拍摄所需的任何图像,然后应用此模型在其上输出分割结果。
The output will in the form of a number (probability) in case of classification problem, or a sequence of integers that locate the mask on the image, ... etc. 在出现分类问题的情况下,输出将采用数字(概率)的形式,或者将整数掩码定位在图像上的整数序列,等等。
You may find the answer here: Tensorflow: how to run prediction (using an image as input) for a trained model? 您可能会在这里找到答案: Tensorflow:如何对经过训练的模型进行预测(使用图像作为输入)?
Just as a note that would be helpful, I highly recommend starting with Keras
if you are a starter with deep learning. 就像一条注释会有所帮助一样,如果您是深度学习的入门者,我强烈建议从
Keras
开始。 Tensorflow
is a great tool but it's low level and requires more complicated details that you don't need to know. Tensorflow
是一个很棒的工具,但是它的级别很低,并且需要您不需要知道的更复杂的细节。
I hope this could help. 我希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.