Skip to content

Commit

Permalink
Disable str labels passed to trainer (#470)
Browse files Browse the repository at this point in the history
* added function to allow missing lables for all tasks

* fixed bug

* minor fixes on testing

* adding dtype in converter

* allow str labels not used for training

* fixed linting

* disable str labels

* reduce lg numerical accuracy

---------

Co-authored-by: BowenD-UCB <[email protected]>
Co-authored-by: Tsz Wai Ko <[email protected]>
  • Loading branch information
3 people authored Dec 17, 2024
1 parent 4ebe7b3 commit 8355485
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/matgl/graph/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def create_line_graph(g: dgl.DGLGraph, threebody_cutoff: float, directed: bool =


def ensure_line_graph_compatibility(
graph: dgl.DGLGraph, line_graph: dgl.DGLGraph, threebody_cutoff: float, directed: bool = False, tol: float = 5e-7
graph: dgl.DGLGraph, line_graph: dgl.DGLGraph, threebody_cutoff: float, directed: bool = False, tol: float = 5e-6
) -> dgl.DGLGraph:
"""Ensure that line graph is compatible with graph.
Expand Down Expand Up @@ -306,7 +306,7 @@ def _ensure_3body_line_graph_compatibility(graph: dgl.DGLGraph, line_graph: dgl.


def _ensure_directed_line_graph_compatibility(
graph: dgl.DGLGraph, line_graph: dgl.DGLGraph, threebody_cutoff: float, tol: float = 5e-7
graph: dgl.DGLGraph, line_graph: dgl.DGLGraph, threebody_cutoff: float, tol: float = 5e-6
) -> dgl.DGLGraph:
"""Ensure that line graph is compatible with graph.
Expand Down
6 changes: 5 additions & 1 deletion src/matgl/graph/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ def __getitem__(self, idx: int):
self.graphs[idx],
self.lattices[idx],
self.state_attr[idx],
{k: torch.tensor(v[idx], dtype=matgl.float_th) for k, v in self.labels.items()},
{
k: torch.tensor(v[idx], dtype=matgl.float_th)
for k, v in self.labels.items()
if not isinstance(v[idx], str)
},
]
if self.include_line_graph:
items.insert(2, self.line_graphs[idx])
Expand Down

0 comments on commit 8355485

Please sign in to comment.