Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ExplainGNNWithHighLevelConcepts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ajay Umakanth
ExplainGNNWithHighLevelConcepts
Commits
7bf0513d
There was an error fetching the commit references. Please try again later.
Commit
7bf0513d
authored
6 months ago
by
AjUm-HEIDI
Browse files
Options
Downloads
Patches
Plain Diff
Set the correct results dir variable
parent
b3333a2b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
GNN/GNN.py
+0
-59
0 additions, 59 deletions
GNN/GNN.py
text_based_datasets_experiment.py
+2
-2
2 additions, 2 deletions
text_based_datasets_experiment.py
with
2 additions
and
61 deletions
GNN/GNN.py
deleted
100644 → 0
+
0
−
59
View file @
b3333a2b
import
torch
import
torch.nn.functional
as
F
from
typing
import
Dict
,
List
,
Optional
,
Tuple
class
GNN
(
torch
.
nn
.
Module
):
def
__init__
(
self
,
device
:
Optional
[
str
]
=
None
):
"""
Base class for Graph Neural Networks, supporting both homogeneous
and heterogeneous GNNs.
Args:
device (Optional[str]): Device to use (
'
cuda
'
or
'
cpu
'
). If None, auto-detect.
"""
super
(
GNN
,
self
).
__init__
()
self
.
device
=
device
if
device
else
(
'
cuda
'
if
torch
.
cuda
.
is_available
()
else
'
cpu
'
)
self
.
best_model_state
=
None
def
forward
(
self
,
*
args
,
**
kwargs
):
"""
Forward pass to be implemented by child classes.
"""
raise
NotImplementedError
(
"
The `forward` method must be implemented in a subclass.
"
)
def
predict
(
self
,
*
args
,
**
kwargs
)
->
torch
.
Tensor
:
"""
Predict labels for a single graph or node, depending on the type of GNN.
To be implemented in child classes if customization is required.
Returns:
torch.Tensor: Predicted label(s).
"""
self
.
eval
()
with
torch
.
no_grad
():
return
self
.
_predict
(
*
args
,
**
kwargs
)
def
predict_all
(
self
,
*
args
,
**
kwargs
)
->
torch
.
Tensor
:
"""
Predict labels for all graphs or nodes, depending on the type of GNN.
To be implemented in child classes if customization is required.
Returns:
torch.Tensor: Predicted labels.
"""
self
.
eval
()
with
torch
.
no_grad
():
return
self
.
_predict_all
(
*
args
,
**
kwargs
)
def
_predict
(
self
,
*
args
,
**
kwargs
)
->
torch
.
Tensor
:
"""
Internal predict method for subclasses to override.
"""
raise
NotImplementedError
(
"
The `_predict` method must be implemented in a subclass.
"
)
def
_predict_all
(
self
,
*
args
,
**
kwargs
)
->
torch
.
Tensor
:
"""
Internal predict_all method for subclasses to override.
"""
raise
NotImplementedError
(
"
The `_predict_all` method must be implemented in a subclass.
"
)
This diff is collapsed.
Click to expand it.
text_based_datasets_experiment.py
+
2
−
2
View file @
7bf0513d
...
...
@@ -213,8 +213,8 @@ def experiment(grouped_keyword_dir, dataset_name, entity_name, iterations=5, num
# Create timestamp directory for all results
timestamp
=
datetime
.
datetime
.
now
().
strftime
(
"
%Y%m%d_%H%M%S
"
)
results
=
Path
(
f
"
evaluation_results/
{
timestamp
}
_
{
dataset_name
}
"
)
results
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
results
_dir
=
Path
(
f
"
evaluation_results/
{
timestamp
}
_
{
dataset_name
}
"
)
results
_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
aggregated_results
=
{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment