Giter VIP home page Giter VIP logo

Comments (4)

layog avatar layog commented on August 16, 2024

Yes, the β (called betas in the code) and ν (called shift_parameters in the code) are trainable. Both of these are defined as variables and hence are trained when training the complete network. These along with BatchNorm parameters are trained when train_step is computed. The initial values are chosen to be 1 for betas and 0 for shift_parameters (just like it is done in the BatchNorm layer) in order to retain the actual information and these are subsequently trained by the network.

from accurate-binary-convolution-network.

ChunyanZhao avatar ChunyanZhao commented on August 16, 2024

`
def ABCLayer(input_tensor, name=None):

     with tf.name_scope(name, "ABCLayer"):

            # Reshaping betas to match the input tensor
            reshaped_betas = tf.reshape(betas,
                                        shape=[no_ApproxConvLayers] + [1] * len(input_tensor.get_shape()),
                                        name="reshaped_betas")

            # Calculating ApproxConv for each shifted input
            ApproxConv_layers = []
            for index in range(no_ApproxConvLayers):
                # Shifting and binarizing input
                shifted_input = tf.clip_by_value(input_tensor + shift_parameters[index], 0., 1.,
                                                 name="shifted_input_" + str(index))
                binarized_activation = tf.sign(shifted_input - 0.5)
                
                # Passing through the ApproxConv layer
                ApproxConv_layers.append(ApproxConvLayer(binarized_activation))
            ApproxConv_output = tf.convert_to_tensor(ApproxConv_layers, dtype=tf.float32,
                                                     name="ApproxConv_output")
            
            # Taking the weighted sum using the betas
            ABC_output = tf.reduce_sum(tf.multiply(ApproxConv_output, reshaped_betas), axis=0)
            return ABC_output`

As is shown above, shift_parameters and reshaped_betas are computed in the same way with the same data, I wonder if all shift_parameters will be trained to the same value. Or I miss something?

from accurate-binary-convolution-network.

layog avatar layog commented on August 16, 2024

You are probably right. This might be a fatal bug in the code, that I have overlooked. Nonetheless, I would have to test this whether all shift_parameters and betas are learning the same values. If you have already tested it, do share your results.

If it actually is a bug, an easy fix would be to initialize shift_parameters and betas from a gaussian (Glorot initialization should be better) rather than fixed values.

P.S. - Thanks for pointing this out

from accurate-binary-convolution-network.

ChunyanZhao avatar ChunyanZhao commented on August 16, 2024

I'm sorry that I haven't tested it, but I find that the paper gives some advise to initializing shift_parameters and betas in supplementary material. Thank you again for your generous share.

from accurate-binary-convolution-network.

Related Issues (7)

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.