Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 2517f5d

Browse files
Rename CodeVectorizer
1 parent e89b5ee commit 2517f5d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

py_example/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ of `PathMinerLoader` to i.e. Tensorflow tensors or ndarrays.
7474

7575
### Model
7676

77-
`model.Code2Vec` contains a model to vectorize snippets of code based on their path-context representation.
78-
This model had been originally implemented as a part of [code2vec](https://github.com/tech-srl/code2vec).
77+
`model.CodeVectorizer` contains a model to vectorize snippets of code based on their path-context representation.
78+
This model works similarly to the part of [code2vec's](https://github.com/tech-srl/code2vec) that is responsible for code vectorization.
7979
It is implemented as a PyTorch module and can be easily reused.
8080

8181
A usage example can be found in `model.ProjectClassifier`.

py_example/data_processing/PathMinerDataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class PathMinerDataset(Dataset):
88

99
# Converts data to PyTorch Tensors for further usage in the model
10-
# Number of contexts per file is limited as it was done in the original implementation of Code2Vec
10+
# Number of contexts per file is limited to allow fast computations
1111
def __init__(self, loader, indices, keep_contexts=200):
1212
self.size = len(indices)
1313
sample = loader.path_contexts.iloc[indices]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
# Implementation of code2vec's vectorization part in PyTorch.
77
# Since it is a PyTorch Module, it can be reused as a part of another pipeline.
8-
class Code2Vec(nn.Module):
8+
class CodeVectorizer(nn.Module):
99

1010
def __init__(self, n_tokens, n_paths, dim):
11-
super(Code2Vec, self).__init__()
11+
super(CodeVectorizer, self).__init__()
1212
self.tokens_embed = nn.Embedding(n_tokens, dim)
1313
self.paths_embed = nn.Embedding(n_paths, dim)
1414
self.transform = nn.Sequential(nn.Linear(3 * dim, dim), nn.Tanh())

py_example/model/ProjectClassifier.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import torch
22
from torch import nn
3-
from model.Code2Vec import Code2Vec
3+
from model.CodeVectorizer import CodeVectorizer
44

55

66
# Classifier distinguishing files between two projects based on code2vec vectorization for files.
77
class ProjectClassifier(nn.Module):
88

99
def __init__(self, n_tokens, n_paths, dim):
1010
super(ProjectClassifier, self).__init__()
11-
self.vectorization = Code2Vec(n_tokens, n_paths, dim)
11+
self.vectorization = CodeVectorizer(n_tokens, n_paths, dim)
1212
self.classifier = nn.Linear(dim, 1)
1313

1414
def forward(self, contexts):

0 commit comments

Comments
 (0)