Git Product home page Git Product logo

Comments (9)

yun-liu avatar yun-liu commented on July 28, 2024

How do you deal with the dilation operation in conv5? Besides, what are the learning rates in conv5?

from rcf.

CangHaiQingYue avatar CangHaiQingYue commented on July 28, 2024

Thanks for your answer. I will check my code and report later.
I used tf.nn.conv2d_transpose() to do dilation operation. The weights was bilinear kernel.
TF was hard to set different learning rate for different layer, so I set the all trainable weights as the same leraning rate which are 1e-6 divide by 10 per 10k iteration.

`def upsample_filt(size):
"""
Make a 2D bilinear kernel suitable for upsampling of the given (h, w) size.
"""
factor = (size + 1) // 2
if size % 2 == 1:
center = factor - 1
else:
center = factor - 0.5
og = np.ogrid[:size, :size]
return (1 - abs(og[0] - center) / factor) * (1 - abs(og[1] - center) / factor)

def bilinear_upsample_weights(factor, number_of_classes):
"""
Create weights matrix for transposed convolution with bilinear filter
initialization.
"""
filter_size = get_kernel_size(factor)

weights = np.zeros((filter_size,
                    filter_size,
                    number_of_classes,
                    number_of_classes), dtype=np.float32)

upsample_kernel = upsample_filt(filter_size)

for i in range(number_of_classes):
    weights[:, :, i, i] = upsample_kernel

return weights

def deconv(inputs, upsample_factor):
input_shape = tf.shape(inputs)

# Calculate the ouput size of the upsampled tensor
upsampled_shape = tf.stack([input_shape[0],
                           input_shape[1] * upsample_factor,
                           input_shape[2] * upsample_factor,
                           1])

upsample_filter_np = bilinear_upsample_weights(upsample_factor, 1)
upsample_filter_tensor = tf.constant(upsample_filter_np)

# Perform the upsampling
upsampled_inputs = tf.nn.conv2d_transpose(inputs, upsample_filter_tensor,
                                          output_shape=upsampled_shape,
                                          strides=[1, upsample_factor, upsample_factor, 1])

return upsampled_inputs`

from rcf.

yun-liu avatar yun-liu commented on July 28, 2024

As I know, tf.nn.conv2d_transpose() is for deconvolution, not for dilation operation. You may misunderstand me. Maybe you can remove the dilation operation, but please note the upsampling scale.

from rcf.

CangHaiQingYue avatar CangHaiQingYue commented on July 28, 2024

Thanks. I found my biggest mistake is set the vgg conv_layer's lr = 0 in my code. After fixed, the results are better than before. Next question maybe to set the different learning_rate for different layer. After study this konwledge point, I will report my results.
I'm wondering that can we consider dilation as a resize operation use bilinear kernel.
If this opinion is true, then we set tf.nn.conv2d_transpose(trainable=False) maybe the right way.
I rear your code and found that at Deconv step, you set lr = 0, I guess that is the same as trainable=False in tensorflow operation.

from rcf.

yun-liu avatar yun-liu commented on July 28, 2024

But dilation is different from resizing.

from rcf.

CangHaiQingYue avatar CangHaiQingYue commented on July 28, 2024

OK..... I will learn the code carefully.

from rcf.

CangHaiQingYue avatar CangHaiQingYue commented on July 28, 2024

Hi,
I've read the paper 'HED' and 'Fully Convolutional Networks for Semantic Segmentation' .
I think dilation is an simple bilinear interpolation with kernel size f. In the FCN, we call it as backwards convolution (sometimes called deconvolution). Weights can be learned or not is not important. HED proved that learned weights provide no noticeable improvements.
Am I right?

from rcf.

yun-liu avatar yun-liu commented on July 28, 2024

I don't know where you got this information, but dilation is nothing with the deconvolution or bilinear interpolation at all. Dilation is just a Caffe implementation of the well-known hole algorithm. Please refer to some tutorials of deep learning for more help.

from rcf.

CangHaiQingYue avatar CangHaiQingYue commented on July 28, 2024

Sorry to waste your time...I misunderstand your mean. you mean atrous algorithm. I used
tf.nn.atrous_conv2d(bottom, filt, rate=2, padding='SAME') to do dilation operation.
hanks for your help.
Its very kind of you!

from rcf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.