Combining 2 Neural Networks












6












$begingroup$


2 images as input, x1 and x2 and try to use convolution as a similarity measure. The idea is that the learned weights substitute more traditional measure of similarity (cross correlation, NN, ...). Defining my forward function as follows:



def forward(self,x1,x2):
out_conv1a = self.conv1(x1)
out_conv2a = self.conv2(out_conv1a)
out_conv3a = self.conv3(out_conv2a)

out_conv1b = self.conv1(x2)
out_conv2b = self.conv2(out_conv1b)
out_conv3b = self.conv3(out_conv2b)


Now for the similarity measure:



out_cat = torch.cat([out_conv3a, out_conv3b],dim=1)
futher_conv = nn.Conv2d(out_cat)


Question is as follows:




  1. Would Depthwise/Separable Convolutions as in the google paper yield any advantage over 2d convolution of the concatenated input. For that matter can convolution be a similarity measure, cross correlation and convolution are very similar.


  2. It is my understanding that the groups=2 option in conv2d would provide 2 separate inputs to train weights with, in this case each of the previous networks weights. How are these combined afterwards?











share|improve this question











$endgroup$




bumped to the homepage by Community 10 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • $begingroup$
    IMHO depthwise/separable convolutions provide marginal improvement and only in specific areas. IMHO ResNet is a better start overall then google's neural networks. And in my head convolutions and cross correlation are completely different things with completely different math behind. You can calculate similarity score based on the output of the layer before the last one. And weights could be completely different for the same results. So IMHO weights are not a good approximation of similarity.
    $endgroup$
    – keiv.fly
    Oct 13 '18 at 22:27












  • $begingroup$
    Before we consider all of those details, how are you going to train your network? What's your target?
    $endgroup$
    – Louis T
    Jan 7 at 1:30
















6












$begingroup$


2 images as input, x1 and x2 and try to use convolution as a similarity measure. The idea is that the learned weights substitute more traditional measure of similarity (cross correlation, NN, ...). Defining my forward function as follows:



def forward(self,x1,x2):
out_conv1a = self.conv1(x1)
out_conv2a = self.conv2(out_conv1a)
out_conv3a = self.conv3(out_conv2a)

out_conv1b = self.conv1(x2)
out_conv2b = self.conv2(out_conv1b)
out_conv3b = self.conv3(out_conv2b)


Now for the similarity measure:



out_cat = torch.cat([out_conv3a, out_conv3b],dim=1)
futher_conv = nn.Conv2d(out_cat)


Question is as follows:




  1. Would Depthwise/Separable Convolutions as in the google paper yield any advantage over 2d convolution of the concatenated input. For that matter can convolution be a similarity measure, cross correlation and convolution are very similar.


  2. It is my understanding that the groups=2 option in conv2d would provide 2 separate inputs to train weights with, in this case each of the previous networks weights. How are these combined afterwards?











share|improve this question











$endgroup$




bumped to the homepage by Community 10 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • $begingroup$
    IMHO depthwise/separable convolutions provide marginal improvement and only in specific areas. IMHO ResNet is a better start overall then google's neural networks. And in my head convolutions and cross correlation are completely different things with completely different math behind. You can calculate similarity score based on the output of the layer before the last one. And weights could be completely different for the same results. So IMHO weights are not a good approximation of similarity.
    $endgroup$
    – keiv.fly
    Oct 13 '18 at 22:27












  • $begingroup$
    Before we consider all of those details, how are you going to train your network? What's your target?
    $endgroup$
    – Louis T
    Jan 7 at 1:30














6












6








6





$begingroup$


2 images as input, x1 and x2 and try to use convolution as a similarity measure. The idea is that the learned weights substitute more traditional measure of similarity (cross correlation, NN, ...). Defining my forward function as follows:



def forward(self,x1,x2):
out_conv1a = self.conv1(x1)
out_conv2a = self.conv2(out_conv1a)
out_conv3a = self.conv3(out_conv2a)

out_conv1b = self.conv1(x2)
out_conv2b = self.conv2(out_conv1b)
out_conv3b = self.conv3(out_conv2b)


Now for the similarity measure:



out_cat = torch.cat([out_conv3a, out_conv3b],dim=1)
futher_conv = nn.Conv2d(out_cat)


Question is as follows:




  1. Would Depthwise/Separable Convolutions as in the google paper yield any advantage over 2d convolution of the concatenated input. For that matter can convolution be a similarity measure, cross correlation and convolution are very similar.


  2. It is my understanding that the groups=2 option in conv2d would provide 2 separate inputs to train weights with, in this case each of the previous networks weights. How are these combined afterwards?











share|improve this question











$endgroup$




2 images as input, x1 and x2 and try to use convolution as a similarity measure. The idea is that the learned weights substitute more traditional measure of similarity (cross correlation, NN, ...). Defining my forward function as follows:



def forward(self,x1,x2):
out_conv1a = self.conv1(x1)
out_conv2a = self.conv2(out_conv1a)
out_conv3a = self.conv3(out_conv2a)

out_conv1b = self.conv1(x2)
out_conv2b = self.conv2(out_conv1b)
out_conv3b = self.conv3(out_conv2b)


Now for the similarity measure:



out_cat = torch.cat([out_conv3a, out_conv3b],dim=1)
futher_conv = nn.Conv2d(out_cat)


Question is as follows:




  1. Would Depthwise/Separable Convolutions as in the google paper yield any advantage over 2d convolution of the concatenated input. For that matter can convolution be a similarity measure, cross correlation and convolution are very similar.


  2. It is my understanding that the groups=2 option in conv2d would provide 2 separate inputs to train weights with, in this case each of the previous networks weights. How are these combined afterwards?








python neural-network image-classification convolution pytorch






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 4 '18 at 0:29









timleathart

2,169726




2,169726










asked Oct 3 '18 at 9:01









Benedict K.Benedict K.

1764




1764





bumped to the homepage by Community 10 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 10 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • $begingroup$
    IMHO depthwise/separable convolutions provide marginal improvement and only in specific areas. IMHO ResNet is a better start overall then google's neural networks. And in my head convolutions and cross correlation are completely different things with completely different math behind. You can calculate similarity score based on the output of the layer before the last one. And weights could be completely different for the same results. So IMHO weights are not a good approximation of similarity.
    $endgroup$
    – keiv.fly
    Oct 13 '18 at 22:27












  • $begingroup$
    Before we consider all of those details, how are you going to train your network? What's your target?
    $endgroup$
    – Louis T
    Jan 7 at 1:30


















  • $begingroup$
    IMHO depthwise/separable convolutions provide marginal improvement and only in specific areas. IMHO ResNet is a better start overall then google's neural networks. And in my head convolutions and cross correlation are completely different things with completely different math behind. You can calculate similarity score based on the output of the layer before the last one. And weights could be completely different for the same results. So IMHO weights are not a good approximation of similarity.
    $endgroup$
    – keiv.fly
    Oct 13 '18 at 22:27












  • $begingroup$
    Before we consider all of those details, how are you going to train your network? What's your target?
    $endgroup$
    – Louis T
    Jan 7 at 1:30
















$begingroup$
IMHO depthwise/separable convolutions provide marginal improvement and only in specific areas. IMHO ResNet is a better start overall then google's neural networks. And in my head convolutions and cross correlation are completely different things with completely different math behind. You can calculate similarity score based on the output of the layer before the last one. And weights could be completely different for the same results. So IMHO weights are not a good approximation of similarity.
$endgroup$
– keiv.fly
Oct 13 '18 at 22:27






$begingroup$
IMHO depthwise/separable convolutions provide marginal improvement and only in specific areas. IMHO ResNet is a better start overall then google's neural networks. And in my head convolutions and cross correlation are completely different things with completely different math behind. You can calculate similarity score based on the output of the layer before the last one. And weights could be completely different for the same results. So IMHO weights are not a good approximation of similarity.
$endgroup$
– keiv.fly
Oct 13 '18 at 22:27














$begingroup$
Before we consider all of those details, how are you going to train your network? What's your target?
$endgroup$
– Louis T
Jan 7 at 1:30




$begingroup$
Before we consider all of those details, how are you going to train your network? What's your target?
$endgroup$
– Louis T
Jan 7 at 1:30










1 Answer
1






active

oldest

votes


















0












$begingroup$


  1. Depthwise separable convolution followed by 1x1 convolution is an alternative to the convenient 2d convolution. They were introduced in https://arxiv.org/abs/1704.04861 to aiming on reducing the computational effort. The combination of depthwise and pointwise convolutions often learn pretty much the same representation as the normal conv.


  2. Depthwise separable conv is an extreme case of grouped conv, where num_groups=num_input_channels. Setting number of groups to 2 means slicing the input into two inputs across the channel dim and learning two separate filters for each sliced input. Here is nice tutorial on that. The output is combined by stacking each group's output. Often this is followed by 1x1 conv to mix the data flow between the groups.







share|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "557"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f39095%2fcombining-2-neural-networks%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0












    $begingroup$


    1. Depthwise separable convolution followed by 1x1 convolution is an alternative to the convenient 2d convolution. They were introduced in https://arxiv.org/abs/1704.04861 to aiming on reducing the computational effort. The combination of depthwise and pointwise convolutions often learn pretty much the same representation as the normal conv.


    2. Depthwise separable conv is an extreme case of grouped conv, where num_groups=num_input_channels. Setting number of groups to 2 means slicing the input into two inputs across the channel dim and learning two separate filters for each sliced input. Here is nice tutorial on that. The output is combined by stacking each group's output. Often this is followed by 1x1 conv to mix the data flow between the groups.







    share|improve this answer









    $endgroup$


















      0












      $begingroup$


      1. Depthwise separable convolution followed by 1x1 convolution is an alternative to the convenient 2d convolution. They were introduced in https://arxiv.org/abs/1704.04861 to aiming on reducing the computational effort. The combination of depthwise and pointwise convolutions often learn pretty much the same representation as the normal conv.


      2. Depthwise separable conv is an extreme case of grouped conv, where num_groups=num_input_channels. Setting number of groups to 2 means slicing the input into two inputs across the channel dim and learning two separate filters for each sliced input. Here is nice tutorial on that. The output is combined by stacking each group's output. Often this is followed by 1x1 conv to mix the data flow between the groups.







      share|improve this answer









      $endgroup$
















        0












        0








        0





        $begingroup$


        1. Depthwise separable convolution followed by 1x1 convolution is an alternative to the convenient 2d convolution. They were introduced in https://arxiv.org/abs/1704.04861 to aiming on reducing the computational effort. The combination of depthwise and pointwise convolutions often learn pretty much the same representation as the normal conv.


        2. Depthwise separable conv is an extreme case of grouped conv, where num_groups=num_input_channels. Setting number of groups to 2 means slicing the input into two inputs across the channel dim and learning two separate filters for each sliced input. Here is nice tutorial on that. The output is combined by stacking each group's output. Often this is followed by 1x1 conv to mix the data flow between the groups.







        share|improve this answer









        $endgroup$




        1. Depthwise separable convolution followed by 1x1 convolution is an alternative to the convenient 2d convolution. They were introduced in https://arxiv.org/abs/1704.04861 to aiming on reducing the computational effort. The combination of depthwise and pointwise convolutions often learn pretty much the same representation as the normal conv.


        2. Depthwise separable conv is an extreme case of grouped conv, where num_groups=num_input_channels. Setting number of groups to 2 means slicing the input into two inputs across the channel dim and learning two separate filters for each sliced input. Here is nice tutorial on that. The output is combined by stacking each group's output. Often this is followed by 1x1 conv to mix the data flow between the groups.








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 11 at 15:15









        Dmytro PrylipkoDmytro Prylipko

        4387




        4387






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Data Science Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f39095%2fcombining-2-neural-networks%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to label and detect the document text images

            Vallis Paradisi

            Tabula Rosettana