Spaces:
Running
Running
Delay some imports to speed up startup.
Browse files
lynxkite-graph-analytics/pyproject.toml
CHANGED
@@ -26,6 +26,7 @@ dev = [
|
|
26 |
"pytest-asyncio>=0.26.0",
|
27 |
]
|
28 |
gpu = [
|
|
|
29 |
"nx-cugraph-cu12>=25.4.0",
|
30 |
"polars[gpu]>=1.25.2",
|
31 |
]
|
|
|
26 |
"pytest-asyncio>=0.26.0",
|
27 |
]
|
28 |
gpu = [
|
29 |
+
"cuml-cu12>=25.2.1",
|
30 |
"nx-cugraph-cu12>=25.4.0",
|
31 |
"polars[gpu]>=1.25.2",
|
32 |
]
|
lynxkite-graph-analytics/src/lynxkite_graph_analytics/ml_ops.py
CHANGED
@@ -8,7 +8,6 @@ from lynxkite.core import workspace
|
|
8 |
from .pytorch import pytorch_core
|
9 |
from lynxkite.core import ops
|
10 |
from tqdm import tqdm
|
11 |
-
import umap
|
12 |
import joblib
|
13 |
import pandas as pd
|
14 |
import pathlib
|
@@ -178,15 +177,19 @@ def view_vectors(
|
|
178 |
min_dist: float = 0.1,
|
179 |
metric: UMAPMetric = UMAPMetric.euclidean,
|
180 |
):
|
|
|
|
|
|
|
|
|
181 |
vec = np.stack(bundle.dfs[table_name][vector_column].to_numpy())
|
182 |
-
|
183 |
-
|
184 |
n_neighbors=n_neighbors,
|
185 |
min_dist=min_dist,
|
186 |
metric=metric.value,
|
187 |
)
|
188 |
-
proj =
|
189 |
-
color =
|
190 |
data = [[*p.tolist(), "", c.item()] for p, c in zip(proj, color)]
|
191 |
if label_column:
|
192 |
for i, row in enumerate(bundle.dfs[table_name][label_column]):
|
|
|
8 |
from .pytorch import pytorch_core
|
9 |
from lynxkite.core import ops
|
10 |
from tqdm import tqdm
|
|
|
11 |
import joblib
|
12 |
import pandas as pd
|
13 |
import pathlib
|
|
|
177 |
min_dist: float = 0.1,
|
178 |
metric: UMAPMetric = UMAPMetric.euclidean,
|
179 |
):
|
180 |
+
try:
|
181 |
+
from cuml.manifold.umap import UMAP
|
182 |
+
except ImportError:
|
183 |
+
from umap import UMAP
|
184 |
vec = np.stack(bundle.dfs[table_name][vector_column].to_numpy())
|
185 |
+
umap = functools.partial(
|
186 |
+
UMAP,
|
187 |
n_neighbors=n_neighbors,
|
188 |
min_dist=min_dist,
|
189 |
metric=metric.value,
|
190 |
)
|
191 |
+
proj = umap(n_components=2).fit_transform(vec)
|
192 |
+
color = umap(n_components=1).fit_transform(vec)
|
193 |
data = [[*p.tolist(), "", c.item()] for p, c in zip(proj, color)]
|
194 |
if label_column:
|
195 |
for i, row in enumerate(bundle.dfs[table_name][label_column]):
|
lynxkite-graph-analytics/src/lynxkite_graph_analytics/pytorch/pytorch_core.py
CHANGED
@@ -6,7 +6,6 @@ import graphlib
|
|
6 |
import pydantic
|
7 |
from lynxkite.core import ops, workspace
|
8 |
import torch
|
9 |
-
import torch_geometric.nn as pyg_nn
|
10 |
import dataclasses
|
11 |
from .. import core
|
12 |
|
@@ -319,6 +318,8 @@ class ModelBuilder:
|
|
319 |
return self.get_config()
|
320 |
|
321 |
def get_config(self) -> ModelConfig:
|
|
|
|
|
322 |
# Split the design into model and loss.
|
323 |
model_nodes = set()
|
324 |
for node_id in self.nodes:
|
|
|
6 |
import pydantic
|
7 |
from lynxkite.core import ops, workspace
|
8 |
import torch
|
|
|
9 |
import dataclasses
|
10 |
from .. import core
|
11 |
|
|
|
318 |
return self.get_config()
|
319 |
|
320 |
def get_config(self) -> ModelConfig:
|
321 |
+
import torch_geometric.nn as pyg_nn
|
322 |
+
|
323 |
# Split the design into model and loss.
|
324 |
model_nodes = set()
|
325 |
for node_id in self.nodes:
|
lynxkite-graph-analytics/src/lynxkite_graph_analytics/pytorch/pytorch_ops.py
CHANGED
@@ -4,7 +4,6 @@ import enum
|
|
4 |
from lynxkite.core import ops
|
5 |
from lynxkite.core.ops import Parameter as P
|
6 |
import torch
|
7 |
-
import torch_geometric.nn as pyg_nn
|
8 |
from .pytorch_core import op, reg, ENV
|
9 |
|
10 |
reg("Input: tensor", outputs=["output"], params=[P.basic("name")])
|
@@ -61,6 +60,8 @@ def dropout(x, *, p=0.0):
|
|
61 |
|
62 |
@op("Linear", weights=True)
|
63 |
def linear(x, *, output_dim=1024):
|
|
|
|
|
64 |
return pyg_nn.Linear(-1, output_dim)
|
65 |
|
66 |
|
|
|
4 |
from lynxkite.core import ops
|
5 |
from lynxkite.core.ops import Parameter as P
|
6 |
import torch
|
|
|
7 |
from .pytorch_core import op, reg, ENV
|
8 |
|
9 |
reg("Input: tensor", outputs=["output"], params=[P.basic("name")])
|
|
|
60 |
|
61 |
@op("Linear", weights=True)
|
62 |
def linear(x, *, output_dim=1024):
|
63 |
+
import torch_geometric.nn as pyg_nn
|
64 |
+
|
65 |
return pyg_nn.Linear(-1, output_dim)
|
66 |
|
67 |
|