GithubHelp home page GithubHelp logo

matching-networks-pytorch's Introduction

matching-networks-pytorch's People

Contributors

boyuanjiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

matching-networks-pytorch's Issues

Pytorch version requirement 0.3.1

Since the update of Pytorch has changed its API for some functions, thus the version >= 0.4.0 is not compatible with this code.
You need to create a new conda environment with python3 and Pytorch 0.3.1 to run.

Otherwise, you will find it stack with problem:"TypeError iteration over a 0-d tensor"
2019-07-28-15-41-54

That's all.

Final accuracy

Do you know what the final accuracies of this model trained on Omniglot are?

The results from the paper are:

5-way/1-shot  = 98.1%
5-way/5-shot  = 98.9%
20-way/1-shot = 93.8%
20-way/5-shot = 98.5%

Thanks
Ben

training objective

The training objective in the original paper is theta, should the loss value be theta? Why is loss in your program a cross entropy loss?

Seems fce are not correctly used

In the forward function of matching_net.py, output of self.g is passed to self.lstm, but the output of self.lstm is not used.

Note the 'output' becomes 'outputs' in 'outputs = self.lstm(output)'

code line 198

        # use fce?
        if self.fce:
            outputs = self.lstm(output)

        # get similarities between support set embeddings and target
        similarites = self.dn(support_set=output[:-1], input_image=output[-1])

How to run this model with newest pytorch?

You need to change code:
line 133 def repackage_hidden(self,h): """Wraps hidden states in new Variables, to detach them from their history.""" if type(h) == Variable: return Variable(h.data) else: return tuple(self.repackage_hidden(v) for v in h)
to
def repackage_hidden(self, h): """Wraps hidden states in new Variables, to detach them from their history.""" if isinstance(h, torch.Tensor): return h.detach() else: return tuple(self.repackage_hidden(v) for v in h)
and all acc.data[0], loss.data[0] should be changed to acc.item(),loss.item().

then you can run the code with newest pytorch.

About the testing

I have a little question about the testing.

In the testing part, the query image always comes from the 5 support classes. But, in practice, there is a totally unknown query coming, how we choose support set (because we don't know its class).

Actually I have tested this query with all possible support sets, but I got many high confidences.

This does not make any sense, we can NOT recognise the query by the output confidence.

That makes me confused about how to use matching net in real practice.

Is my understanding all right?

Cosine distance calculation problem

In the source code, the author calculates the cosine distance as follows.

    sum_support = torch.sum(torch.pow(support_image, 2), 1) 
    support_manitude = sum_support.clamp(eps, float("inf")).rsqrt() 
    dot_product = input_image.unsqueeze(1).bmm(support_image.unsqueeze(2)).squeeze()
    cosine_similarity = dot_product * support_manitude * input_manitude
    similarities.append(cosine_similarity)

But in my opinion, the right the cosine distance should be calculated as follows.

    sum_support = torch.sum(torch.pow(support_image, 2), 1) 
    support_manitude = sum_support.clamp(eps, float("inf")).rsqrt() 
    sum_input = torch.sum(torch.pow(input_image, 2), 1)
    input_manitude = sum_input.clamp(eps, float("inf")).rsqrt()
    dot_product = input_image.unsqueeze(1).bmm(support_image.unsqueeze(2)).squeeze()
    cosine_similarity = dot_product * support_manitude * input_manitude
    similarities.append(cosine_similarity)

Am i right? If not, what is the mistake?

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.