FCN in TensorFlow missing crop layer

人走茶凉 提交于 2019-12-04 08:21:45

问题


I am currently trying to implement FCN for semantic segmentation in TensorFlow as it was previously done in Caffe here.

Unfortunately I'm struggling with following 3 things:

1) How to map "Deconvolution" layer from Caffe to TensorFlow? Is it correctly tf.nn.conv2d_transpose?

2) How to map "Crop" layer from Caffe to TensorFlow? Unfortunately I can't see any alternative in TensorFlow. Is there equivalent for this in TensorFlow?

3) Does Caffe SoftmaxWithLoss correspond to TensorFlow softmax_cross_entropy_with_logits?

Thank you in advance for any advices, hints and help.

EDIT 9th May 2016:

1) I have found out that tf.nn.conv2_transpose really corresponds to deconvolution layer.

2) Crop layer for now seems to be really a problem. I have found out that there actually exists tf.image.resize_image_with_crop_or_pad, but this seems to be impossible to use for this purposes, because it can't work with dynamically created tensors nor with 4D tensors that you need to use after tf.nn.conv2_transpose layer.

Some more information might be on: https://github.com/tensorflow/tensorflow/issues/2049

EDIT 17th May 2016:

I have followed @24hours advice and build FCN in tensorflow, though I was not able to make it train on data of the arbitrary size.

2) Crop layer is really not needed.

3) I have used tf.nn.sparse_softmax_cross_entropy_with_logits at the end and it worked for me.


回答1:


Thanks to the advice from @24hours I have found answer to all the 3 questions. Unfortunately FCN of arbitrary size in tensorflow is a bit more complicated than in caffe, but hopefully I'll solve that soon as well.

1) tf.nn.conv2d_transpose can be used.

2) Crop layer is not needed, output_size of the tf.nn.conv2d_transpose layer can be used instead.

3) At the end I have used tf.nn.sparse_softmax_cross_entropy_with_logits




回答2:


I found the way for solving arbitrary size image in tensorflow, by implementing crop layer. Now it can be used any size of image you want, when just single image is passed. More about my solution is here: https://stackoverflow.com/a/45632285/3134418



来源:https://stackoverflow.com/questions/36746860/fcn-in-tensorflow-missing-crop-layer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!