repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/test/python/test_dist_feature.py | test/python/test_dist_feature.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/test/python/test_vineyard.py | test/python/test_vineyard.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/test/python/test_dist_subgraph_loader.py | test/python/test_dist_subgraph_loader.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/test/python/test_pyg_remote_backend.py | test/python/test_pyg_remote_backend.py | import unittest
from collections import defaultdict
from typing import List
import graphlearn_torch as glt
import torch
from dist_test_utils import *
from dist_test_utils import _prepare_hetero_dataset
from graphlearn_torch.distributed.dist_client import request_server
from graphlearn_torch.distributed.dist_server imp... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/test/python/test_neighbor_sampler.py | test/python/test_neighbor_sampler.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/docs/conf.py | docs/conf.py | # Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/train_sage_prod_with_trim.py | examples/train_sage_prod_with_trim.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/train_sage_ogbn_products.py | examples/train_sage_ogbn_products.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/feature_mp.py | examples/feature_mp.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/graph_sage_unsup_ppi.py | examples/graph_sage_unsup_ppi.py | import os.path as osp
import torch
import torch.nn.functional as F
import tqdm
from sklearn.linear_model import SGDClassifier
from sklearn.metrics import f1_score
from sklearn.multioutput import MultiOutputClassifier
from torch_geometric.data import Batch
from torch_geometric.datasets import PPI
from torch_geometric.... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/seal_link_pred.py | examples/seal_link_pred.py | import math
import time
import os.path as osp
from itertools import chain
import graphlearn_torch as glt
import numpy as np
import torch
import torch.nn.functional as F
from scipy.sparse.csgraph import shortest_path
from sklearn.metrics import roc_auc_score
from torch.nn import BCEWithLogitsLoss, Conv1d, MaxPool1d, M... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/hetero/train_hgt_mag_mp.py | examples/hetero/train_hgt_mag_mp.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/hetero/train_hgt_mag.py | examples/hetero/train_hgt_mag.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/hetero/bipartite_sage_unsup.py | examples/hetero/bipartite_sage_unsup.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/hetero/hierarchical_sage.py | examples/hetero/hierarchical_sage.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/distributed/dist_train_sage_supervised.py | examples/distributed/dist_train_sage_supervised.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/distributed/partition_ogbn_dataset.py | examples/distributed/partition_ogbn_dataset.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/distributed/run_dist_train_sage_sup.py | examples/distributed/run_dist_train_sage_sup.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/distributed/dist_sage_unsup/preprocess_template.py | examples/distributed/dist_sage_unsup/preprocess_template.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/distributed/dist_sage_unsup/dist_sage_unsup.py | examples/distributed/dist_sage_unsup/dist_sage_unsup.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/distributed/server_client_mode/sage_supervised_client.py | examples/distributed/server_client_mode/sage_supervised_client.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/distributed/server_client_mode/sage_supervised_server.py | examples/distributed/server_client_mode/sage_supervised_server.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/gpt/utils.py | examples/gpt/utils.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/gpt/arxiv.py | examples/gpt/arxiv.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/dist_train_rgnn.py | examples/igbh/dist_train_rgnn.py | # Copyright 2023 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/partition.py | examples/igbh/partition.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/rgnn.py | examples/igbh/rgnn.py | # Copyright 2023 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/train_rgnn_multi_gpu.py | examples/igbh/train_rgnn_multi_gpu.py | # Copyright 2023 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/dataset.py | examples/igbh/dataset.py | # Copyright 2023 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/build_partition_feature.py | examples/igbh/build_partition_feature.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/mlperf_logging_utils.py | examples/igbh/mlperf_logging_utils.py | import os
from mlperf_logging import mllog
from mlperf_logging.mllog import constants
from mlperf_logging.mllog.mllog import MLLogger
def get_mlperf_logger(path, filename='mlperf_gnn.log'):
mllog.config(filename=os.path.join(path, filename))
mllogger = mllog.get_mllogger()
mllogger.logger.propagate = False... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/download.py | examples/igbh/download.py | import tarfile, hashlib, os
import os.path as osp
from tqdm import tqdm
import urllib.request as ur
# https://github.com/IllinoisGraphBenchmark/IGB-Datasets/blob/main/igb/download.py
GBFACTOR = float(1 << 30)
def decide_download(url):
d = ur.urlopen(url)
size = int(d.info()["Content-Length"])/GBFACTOR
### conf... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/__init__.py | examples/igbh/__init__.py | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false | |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/compress_graph.py | examples/igbh/compress_graph.py | # Copyright 2023 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/split_seeds.py | examples/igbh/split_seeds.py | import argparse
import os.path as osp
import torch
class SeedSplitter(object):
def __init__(self,
path,
dataset_size='tiny',
use_label_2K=True,
random_seed=42,
validation_frac=0.01):
self.path = path
self.dataset_size = dataset_size
... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/igbh/utilities.py | examples/igbh/utilities.py | import os
import time
import torch
def create_ckpt_folder(base_dir, prefix="ckpt"):
timestamp = time.strftime("%Y%m%d-%H%M%S")
folder_name = f"{prefix}_{timestamp}" if prefix else timestamp
full_path = os.path.join(base_dir, folder_name)
if not os.path.exists(full_path):
os.makedirs(full_path)
... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/multi_gpu/train_sage_ogbn_papers100m.py | examples/multi_gpu/train_sage_ogbn_papers100m.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/pai/ogbn_products/train_products_sage.py | examples/pai/ogbn_products/train_products_sage.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/pai/ogbn_products/data_preprocess.py | examples/pai/ogbn_products/data_preprocess.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
alibaba/graphlearn-for-pytorch | https://github.com/alibaba/graphlearn-for-pytorch/blob/88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9/examples/pai/ogbn_products/dist_train_products_sage.py | examples/pai/ogbn_products/dist_train_products_sage.py | # Copyright 2022 Alibaba Group Holding Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | python | Apache-2.0 | 88ff111ac0d9e45c6c9d2d18cfc5883dca07e9f9 | 2026-01-05T07:14:39.718240Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/setup.py | setup.py |
from setuptools import setup
setup(name='stable_nalu',
version='0.1.0',
description='Implementation of NALU with stable training',
url='https://github.com/AndreasMadsen/publication-stable-nalu',
author='Andreas Madsen',
author_email='amwebdk@gmail.com',
license='MIT',
package... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/experiments/sequential_mnist.py | experiments/sequential_mnist.py |
import os
import ast
import math
import torch
import stable_nalu
import argparse
# Parse arguments
parser = argparse.ArgumentParser(description='Run either the MNIST counting or MNIST Arithmetic task')
parser.add_argument('--layer-type',
action='store',
default='NALU',
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/experiments/sequential_svhn.py | experiments/sequential_svhn.py |
import os
import ast
import math
import torch
import stable_nalu
import argparse
# Parse arguments
parser = argparse.ArgumentParser(description='Run either the SVHN counting or SVHN Arithmetic task')
parser.add_argument('--layer-type',
action='store',
default='NALU',
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/experiments/simple_function_static.py | experiments/simple_function_static.py |
import os
import ast
import math
import torch
import stable_nalu
import argparse
# Parse arguments
parser = argparse.ArgumentParser(description='Runs the simple function static task')
parser.add_argument('--layer-type',
action='store',
default='NALU',
choice... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/experiments/simple_function_recurrent.py | experiments/simple_function_recurrent.py |
import math
import torch
import stable_nalu
import argparse
# Parse arguments
parser = argparse.ArgumentParser(description='Runs the simple function static task')
parser.add_argument('--layer-type',
action='store',
default='NALU',
choices=list(stable_nalu.ne... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/experiments/number_translation.py | experiments/number_translation.py |
import math
import torch
import stable_nalu
import argparse
# Parse arguments
parser = argparse.ArgumentParser(description='Run the number translation task')
parser.add_argument('--layer-type',
action='store',
default='NALU',
choices=list(stable_nalu.network... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/__init__.py | stable_nalu/__init__.py |
from . import dataset
from . import functional
from . import layer
from . import network
from . import reader
from . import writer | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/abstract/_extended_torch_module.py | stable_nalu/abstract/_extended_torch_module.py |
import torch
import collections
from ..writer import DummySummaryWriter
class NoRandomScope:
def __init__(self, module):
self._module = module
def __enter__(self):
self._module._disable_random()
def __exit__(self, type, value, traceback):
self._module._enable_random()
ret... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/abstract/__init__.py | stable_nalu/abstract/__init__.py |
from ._extended_torch_module import ExtendedTorchModule | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/writer/save_model.py | stable_nalu/writer/save_model.py |
import os
import os.path as path
import torch
THIS_DIR = path.dirname(path.realpath(__file__))
if 'SAVE_DIR' in os.environ:
SAVE_DIR = os.environ['SAVE_DIR']
else:
SAVE_DIR = path.join(THIS_DIR, '../../save')
def save_model(name, model):
save_file = path.join(SAVE_DIR, name) + '.pth'
os.makedirs(pat... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/writer/summary_writer.py | stable_nalu/writer/summary_writer.py |
import os
import shutil
import os.path as path
import torch
import numpy as np
from tensorboardX import SummaryWriter as SummaryWriterRaw
THIS_DIR = path.dirname(path.realpath(__file__))
if 'TENSORBOARD_DIR' in os.environ:
TENSORBOARD_DIR = os.environ['TENSORBOARD_DIR']
else:
TENSORBOARD_DIR = path.join(THIS... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/writer/__init__.py | stable_nalu/writer/__init__.py |
from .summary_writer import DummySummaryWriter, SummaryWriter
from .save_model import save_model
| python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/integration_test/simple_function_static_linear_add.py | stable_nalu/integration_test/simple_function_static_linear_add.py |
import numpy as np
import torch
import stable_nalu
def test_linear_add_can_have_zero_loss():
# Prepear data
dataset = stable_nalu.dataset.SimpleFunctionStaticDataset(
operation='add',
seed=0
)
dataset_eval = iter(dataset.fork(input_range=1).dataloader(batch_size=128))
# Setup pre-... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/integration_test/__init__.py | stable_nalu/integration_test/__init__.py | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false | |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/reader/tensorboard_metric_reader.py | stable_nalu/reader/tensorboard_metric_reader.py |
import re
import ast
import pandas
import collections
import multiprocessing
from tqdm import tqdm
import numpy as np
import tensorflow as tf
from .tensorboard_reader import TensorboardReader
def _parse_numpy_str(array_string):
pattern = r'''# Match (mandatory) whitespace between...
(?<=\]) # ] ... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/reader/tensorboard_reader.py | stable_nalu/reader/tensorboard_reader.py |
import os
import os.path as path
import tensorflow as tf
def _listdir_filter_hidden_files(dirpath):
files = os.listdir(dirpath)
files = filter(lambda filename: filename[0] != '.', files)
return list(files)
class TensorboardReader:
"""Reads the final values (before reaching NaN) from a directory of
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/reader/__init__.py | stable_nalu/reader/__init__.py |
from .tensorboard_metric_reader import TensorboardMetricReader
from .tensorboard_reader import TensorboardReader
| python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/hard_softmax_nac.py | stable_nalu/layer/hard_softmax_nac.py |
import math
import torch
from ..abstract import ExtendedTorchModule
from ..functional import sparsity_error
from ._abstract_recurrent_cell import AbstractRecurrentCell
class HardSoftmaxNACLayer(ExtendedTorchModule):
"""Implements the NAC (Neural Accumulator)
Arguments:
in_features: number of ingoing... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/regualized_linear_mnac.py | stable_nalu/layer/regualized_linear_mnac.py |
import scipy.optimize
import numpy as np
import torch
import math
from ..abstract import ExtendedTorchModule
from ..functional import mnac, sparsity_error
from ._abstract_recurrent_cell import AbstractRecurrentCell
class RegualizedLinearMNACLayer(ExtendedTorchModule):
"""Implements the NAC (Neural Accumulator)
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/gradient_bandit_nac.py | stable_nalu/layer/gradient_bandit_nac.py |
import math
import torch
from ..abstract import ExtendedTorchModule
from ..functional import sparsity_error
from ._abstract_recurrent_cell import AbstractRecurrentCell
class GradientBanditNACLayer(ExtendedTorchModule):
"""Implements the NAC (Neural Accumulator)
Arguments:
in_features: number of ingo... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/generalized_test.py | stable_nalu/layer/generalized_test.py |
from nose.tools import *
import numpy as np
import torch
from stable_nalu.layer import GeneralizedLayer
def test_generalized_layer_linear():
x_np = np.random.randn(64, 100).astype(np.float32)
x_tensor = torch.tensor(x_np)
layer = GeneralizedLayer(100, 2, 'linear')
layer.reset_parameters()
y_ten... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/gradient_bandit_nalu.py | stable_nalu/layer/gradient_bandit_nalu.py |
from .gradient_bandit_nac import GradientBanditNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class GradientBanditNALULayer(AbstractNALULayer):
"""Implements the NALU (Neural Arithmetic Logic Unit)
Arguments:
in_features: number of i... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/pos_nac.py | stable_nalu/layer/pos_nac.py |
import scipy.optimize
import numpy as np
import torch
from ..functional import nac_weight, sparsity_error
from ..abstract import ExtendedTorchModule
from ._abstract_recurrent_cell import AbstractRecurrentCell
class PosNACLayer(ExtendedTorchModule):
"""Implements the NAC (Neural Accumulator)
Arguments:
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/linear_nac.py | stable_nalu/layer/linear_nac.py |
import scipy.optimize
import numpy as np
import torch
from ..abstract import ExtendedTorchModule
from ._abstract_recurrent_cell import AbstractRecurrentCell
class LinearNACLayer(ExtendedTorchModule):
"""Implements the RegualizedLinearNAC
Arguments:
in_features: number of ingoing features
out... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/basic_test.py | stable_nalu/layer/basic_test.py |
from nose.tools import *
import numpy as np
import torch
from stable_nalu.layer import BasicLayer
def test_basic_layer_linear():
x_np = np.random.RandomState(1).randn(64, 100).astype(np.float32)
x_tensor = torch.tensor(x_np)
torch.manual_seed(1)
layer = BasicLayer(100, 2, activation='linear')
l... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/nalu.py | stable_nalu/layer/nalu.py |
from .nac import NACLayer
from .mnac import MNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class NALULayer(AbstractNALULayer):
"""Implements the NALU (Neural Arithmetic Logic Unit)
Arguments:
in_features: number of ingoing features
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/independent_nalu.py | stable_nalu/layer/independent_nalu.py |
from .independent_nac import IndependentNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class IndependentNALULayer(AbstractNALULayer):
"""Implements the NALU (Neural Arithmetic Logic Unit)
Arguments:
in_features: number of ingoing fea... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/mnac.py | stable_nalu/layer/mnac.py |
import math
import torch
import numpy as np
import scipy.optimize
from ..functional import mnac, sparsity_error
from ..abstract import ExtendedTorchModule
from ._abstract_recurrent_cell import AbstractRecurrentCell
class MNACLayer(ExtendedTorchModule):
"""Implements the NAC (Neural Accumulator)
Arguments:
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/gumbel_nalu.py | stable_nalu/layer/gumbel_nalu.py |
from .gumbel_nac import GumbelNACLayer
from .gumbel_mnac import GumbelMNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class GumbelNALULayer(AbstractNALULayer):
"""Implements the Gumbel NALU (Neural Arithmetic Logic Unit)
Arguments:
i... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/regualized_linear_nalu.py | stable_nalu/layer/regualized_linear_nalu.py |
from .regualized_linear_nac import RegualizedLinearNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class RegualizedLinearNALULayer(AbstractNALULayer):
"""Implements the NALU (Neural Arithmetic Logic Unit)
Arguments:
in_features: numbe... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/re_regualized_linear_mnac.py | stable_nalu/layer/re_regualized_linear_mnac.py |
import scipy.optimize
import numpy as np
import torch
import math
from ..abstract import ExtendedTorchModule
from ..functional import mnac, Regualizer, RegualizerNMUZ, sparsity_error
from ._abstract_recurrent_cell import AbstractRecurrentCell
class ReRegualizedLinearMNACLayer(ExtendedTorchModule):
"""Implements ... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/silly_re_regualized_linear_mnac.py | stable_nalu/layer/silly_re_regualized_linear_mnac.py |
import scipy.optimize
import numpy as np
import torch
import math
from ..abstract import ExtendedTorchModule
from ..functional import mnac, sparsity_error
from ._abstract_recurrent_cell import AbstractRecurrentCell
class SillyReRegualizedLinearMNACLayer(ExtendedTorchModule):
"""Implements the NAC (Neural Accumul... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/_abstract_recurrent_cell.py | stable_nalu/layer/_abstract_recurrent_cell.py |
import torch
from ..abstract import ExtendedTorchModule
class AbstractRecurrentCell(ExtendedTorchModule):
def __init__(self, Op, input_size, hidden_size, writer=None, **kwargs):
super().__init__('recurrent', writer=writer, **kwargs)
self.input_size = input_size
self.hidden_size = hidden_si... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/independent_nac.py | stable_nalu/layer/independent_nac.py |
import torch
from ..functional import nac_weight, sparsity_error
from .nac import NACLayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class IndependentNACLayer(NACLayer):
def forward(self, input, reuse=False):
W = nac_weight(self.W_hat, self.M_hat, mode='independent')
self.writer... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/re_regualized_linear_nac.py | stable_nalu/layer/re_regualized_linear_nac.py |
import scipy.optimize
import numpy as np
import torch
import math
from ..abstract import ExtendedTorchModule
from ..functional import Regualizer, RegualizerNAUZ, sparsity_error
from ._abstract_recurrent_cell import AbstractRecurrentCell
class ReRegualizedLinearNACLayer(ExtendedTorchModule):
"""Implements the Reg... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/re_regualized_linear_nalu.py | stable_nalu/layer/re_regualized_linear_nalu.py |
from .re_regualized_linear_nac import ReRegualizedLinearNACLayer
from .re_regualized_linear_mnac import ReRegualizedLinearMNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class ReRegualizedLinearNALULayer(AbstractNALULayer):
"""Implements the NALU... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/pos_nalu.py | stable_nalu/layer/pos_nalu.py |
from .pos_nac import PosNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class PosNALULayer(AbstractNALULayer):
"""Implements the NALU (Neural Arithmetic Logic Unit)
Arguments:
in_features: number of ingoing features
out_featur... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/gumbel_nac.py | stable_nalu/layer/gumbel_nac.py |
import torch
from ..abstract import ExtendedTorchModule
from ..functional import sample_gumbel_softmax, batch_linear
from ._abstract_recurrent_cell import AbstractRecurrentCell
class GumbelNACLayer(ExtendedTorchModule):
"""Implements the NAC (Neural Accumulator)
Arguments:
in_features: number of ing... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/hard_softmax_nalu.py | stable_nalu/layer/hard_softmax_nalu.py |
from .hard_softmax_nac import HardSoftmaxNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class HardSoftmaxNALULayer(AbstractNALULayer):
"""Implements the NALU (Neural Arithmetic Logic Unit)
Arguments:
in_features: number of ingoing fe... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/basic.py | stable_nalu/layer/basic.py |
import math
import torch
from ..functional import sparsity_error
from ..abstract import ExtendedTorchModule
from ._abstract_recurrent_cell import AbstractRecurrentCell
ACTIVATIONS = {
'Tanh': torch.tanh,
'Sigmoid': torch.sigmoid,
'ReLU6': torch.nn.functional.relu6,
'Softsign': torch.nn.functional.sof... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/linear_nalu.py | stable_nalu/layer/linear_nalu.py |
from .linear_nac import LinearNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class LinearNALULayer(AbstractNALULayer):
"""Implements the NALU (Neural Arithmetic Logic Unit)
Arguments:
in_features: number of ingoing features
o... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/gumbel_mnac.py | stable_nalu/layer/gumbel_mnac.py |
import torch
from ..abstract import ExtendedTorchModule
from ..functional import mnac
from ._abstract_recurrent_cell import AbstractRecurrentCell
class GumbelMNACLayer(ExtendedTorchModule):
"""Implements the NAC (Neural Accumulator)
Arguments:
in_features: number of ingoing features
out_feat... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/__init__.py | stable_nalu/layer/__init__.py |
from .basic import BasicLayer, BasicCell
from .nac import NACLayer, NACCell
from .nalu import NALULayer, NALUCell
from .gumbel_nac import GumbelNACLayer, GumbelNACCell
from .gumbel_nalu import GumbelNALULayer, GumbelNALUCell
from .linear_nac import LinearNACLayer, LinearNACCell
from .linear_nalu import LinearNALULa... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/_abstract_nalu.py | stable_nalu/layer/_abstract_nalu.py |
import math
import torch
from ..abstract import ExtendedTorchModule
torch.nn.functional.gumbel_softmax
class AbstractNALULayer(ExtendedTorchModule):
"""Implements the NALU (Neural Arithmetic Logic Unit)
Arguments:
in_features: number of ingoing features
out_features: number of outgoing feat... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/nac.py | stable_nalu/layer/nac.py |
import scipy.optimize
import numpy as np
import torch
from ..functional import nac_weight, sparsity_error, RegualizerNAUZ
from ..abstract import ExtendedTorchModule
from ._abstract_recurrent_cell import AbstractRecurrentCell
def nac_w_variance(r):
"""Calculates the variance of W.
Asumming \hat{w} and \hat{m... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/regualized_linear_nac.py | stable_nalu/layer/regualized_linear_nac.py |
import scipy.optimize
import numpy as np
import torch
from ..abstract import ExtendedTorchModule
from ._abstract_recurrent_cell import AbstractRecurrentCell
class RegualizedLinearNACLayer(ExtendedTorchModule):
"""Implements the RegualizedLinearNAC
Arguments:
in_features: number of ingoing features
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/generalized.py | stable_nalu/layer/generalized.py |
import torch
from .basic import BasicLayer, BasicCell
from .nac import NACLayer, NACCell
from .mnac import MNACLayer, MNACCell
from .nalu import NALULayer, NALUCell
from .pos_nac import PosNACLayer, PosNACCell
from .pos_nalu import PosNALULayer, PosNALUCell
from .gumbel_nac import GumbelNACLayer, GumbelNACCell
fro... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/softmax_nalu.py | stable_nalu/layer/softmax_nalu.py |
from .softmax_nac import SoftmaxNACLayer
from ._abstract_nalu import AbstractNALULayer
from ._abstract_recurrent_cell import AbstractRecurrentCell
class SoftmaxNALULayer(AbstractNALULayer):
"""Implements the NALU (Neural Arithmetic Logic Unit)
Arguments:
in_features: number of ingoing features
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/re_regualized_linear_pos_nac.py | stable_nalu/layer/re_regualized_linear_pos_nac.py |
import scipy.optimize
import numpy as np
import torch
import math
from ..abstract import ExtendedTorchModule
from ..functional import mnac, Regualizer, sparsity_error, RegualizerNMUZ
from ._abstract_recurrent_cell import AbstractRecurrentCell
class ReRegualizedLinearPosNACLayer(ExtendedTorchModule):
"""Implement... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/layer/softmax_nac.py | stable_nalu/layer/softmax_nac.py |
import math
import torch
from ..abstract import ExtendedTorchModule
from ..functional import sparsity_error
from ._abstract_recurrent_cell import AbstractRecurrentCell
class SoftmaxNACLayer(ExtendedTorchModule):
"""Implements the NAC (Neural Accumulator)
Arguments:
in_features: number of ingoing fea... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/number_translation_test.py | stable_nalu/dataset/number_translation_test.py |
from nose.tools import *
import torch
import numpy as np
from stable_nalu.dataset import NumberTranslationDataset
def encode_as_string(number):
return ' '.join(NumberTranslationDataset.encode(number, as_strings=True))
def test_number_encoding():
assert_equal(encode_as_string(1), 'one')
assert_equal(enc... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/simple_function_recurrent_test.py | stable_nalu/dataset/simple_function_recurrent_test.py |
from nose.tools import *
import scipy.stats
import torch
import numpy as np
from stable_nalu.dataset import SimpleFunctionRecurrentDataset
def test_batch_shape():
dataset = SimpleFunctionRecurrentDataset(
operation='add', seed=0
)
dataset_test = iter(dataset.fork(seq_length=16).dataloader(batch_... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/sequential_mnist.py | stable_nalu/dataset/sequential_mnist.py |
import os.path as path
import numpy as np
import torch
import torch.utils.data
import torchvision
from typing import Tuple, NamedTuple, Union
from ._dataloader import DataLoaderCudaWrapper
from ._partial_dataset import PartialDataset
class ItemShape(NamedTuple):
input: Tuple[Union[None, int], ...]
target: Tu... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/sequential_svhn.py | stable_nalu/dataset/sequential_svhn.py |
import os.path as path
import numpy as np
import torch
import torch.utils.data
import torchvision
from typing import Tuple, NamedTuple, Union
from ._dataloader import DataLoaderCudaWrapper
from ._partial_dataset import PartialDataset
class ItemShape(NamedTuple):
input: Tuple[Union[None, int], ...]
target: Tu... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/_dataloader.py | stable_nalu/dataset/_dataloader.py |
class DataLoaderCudaWrapper:
def __init__(self, batcher):
self._batcher = batcher
def __getattr__(self, name):
return getattr(self._batcher, name)
def __iter__(self):
batcher = iter(self._batcher)
return map(lambda values: (value.cuda() for value in values), batcher)
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/sequential_mnist_test.py | stable_nalu/dataset/sequential_mnist_test.py |
from nose.tools import *
import torch
import numpy as np
from stable_nalu.dataset import SequentialMnistDataset
def test_seed_gives_consistent_output():
dataset_a = SequentialMnistDataset(
operation='count',
seed=0
).fork(seq_length=1, subset='train')
dataset_b = SequentialMnistDataset(... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/simple_function_static_test.py | stable_nalu/dataset/simple_function_static_test.py |
from nose.tools import *
import scipy.stats
import torch
import numpy as np
from stable_nalu.dataset import SimpleFunctionStaticDataset
def test_solveable_by_linear_algebra():
dataset = SimpleFunctionStaticDataset(
operation='add', seed=0
)
dataset_test = iter(dataset.fork(input_range=1).dataloa... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/simple_function_static.py | stable_nalu/dataset/simple_function_static.py |
import numpy as np
from ._simple_function_abstact import SimpleFunctionDataset
class SimpleFunctionStaticDataset(SimpleFunctionDataset):
def __init__(self, operation,
input_size=100,
**kwargs):
super().__init__(operation, input_size,
**kwargs)
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/__init__.py | stable_nalu/dataset/__init__.py |
from .simple_function_static import SimpleFunctionStaticDataset
from .simple_function_recurrent import SimpleFunctionRecurrentDataset
from .sequential_mnist import SequentialMnistDataset
from .sequential_svhn import SequentialSvhnDataset
from .number_translation import NumberTranslationDataset
| python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
AndreasMadsen/stable-nalu | https://github.com/AndreasMadsen/stable-nalu/blob/b3296ace137ffa4854edeef3759f1578b7650210/stable_nalu/dataset/simple_function_recurrent.py | stable_nalu/dataset/simple_function_recurrent.py |
from ._simple_function_abstact import SimpleFunctionDataset
class SimpleFunctionRecurrentDataset(SimpleFunctionDataset):
def __init__(self, operation,
vector_size=10,
min_subset_length=1,
max_subset_length=5,
min_subset_overlap=1,
... | python | MIT | b3296ace137ffa4854edeef3759f1578b7650210 | 2026-01-05T07:14:37.360899Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.