Giter Site home page Giter Site logo

Comments (7)

SpirinEgor avatar SpirinEgor commented on June 25, 2024 1

It seems that there are correct steps. Could you provide more information:

  • The mined paths from the code snippet
  • The input tensors shapes (they should be something like [5; n_paths])

Also, the model was trained with masked method names, so you should replace them too in your example. As far as I remember, mask token in <MN>. But you can check it. It should be in the top of the label_to_id counter. The correct code snippet is

def <MN>(n):
    if n == 0:
        return 1
    else:
        return n * <MN>(n-1)

Output shape is [7; 1; vocab size], so correct decoding is:

# [7]
predictions = output.squeeze(1).argmax(-1)
labels = [id_to_label(i.item()) for i in predictions]

from code2seq.

SpirinEgor avatar SpirinEgor commented on June 25, 2024

Hi!

First of all, you need to extract paths from the code snippet. This should be done by the tool you used for model training.

After that, you should write a little wrapper to pass your datapoint into the model. Look into an example from readme for correct model loading. Pass your example into the model according to forward method signature.

from code2seq.

Thirunayan22 avatar Thirunayan22 commented on June 25, 2024

Hi @SpirinEgor, thanks for responding !
To train the model I downloaded the dataset and ran the train script provided in the readme. I am a bit unclear, what do you mean by the "tool" used for model training?

from code2seq.

SpirinEgor avatar SpirinEgor commented on June 25, 2024

What dataset did you download?

The tool I was speaking about is a tool for extracting paths from AST of code. There are some different ways to do it:

  1. JavaExtractor from original code2seq repo by Alon
  2. astminer
  3. PSIMiner

All these tools use different parsers therefore they build different ASTs and extract different paths.

from code2seq.

hehehwang avatar hehehwang commented on June 25, 2024

hello, i'm doing same thing with my own python ast miner
can you confirm whether i'm doing correctly?
https://gist.github.com/hehehwang/d058c6fca986a5b479afe10245f63a3e
(i think something went wrong since it's keep printing out and token..)

thank you!

from code2seq.

hehehwang avatar hehehwang commented on June 25, 2024

seems that i've made a silly mistake on decoding.. thank you for your help!
now it works just fine and clear (without mask token though)

thanks again!

from code2seq.

SpirinEgor avatar SpirinEgor commented on June 25, 2024

Awesome!
If you have other questions, feel free to open an issue!

from code2seq.

Related Issues (14)

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.