repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
VIBUS
VIBUS-master/pretrain/models/modules/common.py
import collections from enum import Enum import torch.nn as nn import MinkowskiEngine as ME class NormType(Enum): BATCH_NORM = 0 INSTANCE_NORM = 1 INSTANCE_BATCH_NORM = 2 def get_norm(norm_type, n_channels, D, bn_momentum=0.1): if norm_type == NormType.BATCH_NORM: return ME.MinkowskiBatchNorm(n_channels...
6,916
30.875576
97
py
VIBUS
VIBUS-master/pretrain/models/modules/resnet_block.py
import torch.nn as nn from models.modules.common import ConvType, NormType, get_norm, conv from MinkowskiEngine import MinkowskiReLU class BasicBlockBase(nn.Module): expansion = 1 NORM_TYPE = NormType.BATCH_NORM def __init__(self, inplanes, planes, stride=1, ...
3,174
23.423077
100
py
VIBUS
VIBUS-master/pretrain/demo/scannet.py
# Copyright (c) Chris Choy (chrischoy@ai.stanford.edu). # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, ...
5,641
34.2625
94
py
VIBUS
VIBUS-master/pretrain/demo/stanford.py
# Copyright (c) Chris Choy (chrischoy@ai.stanford.edu). # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, ...
6,143
34.72093
98
py
VIBUS
VIBUS-master/pretrain/lib/hack.py
import os import torch from tqdm import tqdm import time from logging import log, ERROR def check_mem(cuda_device): devices_info = os.popen('"/usr/bin/nvidia-smi" --query-gpu=memory.total,memory.used --format=csv,nounits,noheader').read().strip().split("\n") total, used = devices_info[int(cuda_device)].split('...
864
28.827586
146
py
VIBUS
VIBUS-master/pretrain/lib/test.py
import logging import os import shutil import tempfile import warnings import numpy as np import torch import torch.nn as nn from sklearn.metrics import average_precision_score from sklearn.preprocessing import label_binarize from lib.utils import Timer, AverageMeter, precision_at_one, fast_hist, per_class_iu, \ ...
6,589
33.322917
97
py
VIBUS
VIBUS-master/pretrain/lib/dataloader.py
import torch import math from torch.utils.data.sampler import Sampler import torch.distributed as dist class InfSampler(Sampler): """Samples elements randomly, without replacement. Arguments: data_source (Dataset): dataset to sample from """ def __init__(self, data_source, shuffle=Fals...
2,169
27.933333
80
py
VIBUS
VIBUS-master/pretrain/lib/utils.py
import json import logging import os import errno import time import numpy as np import torch from lib.pc_utils import colorize_pointcloud, save_point_cloud from lib.distributed_utils import get_world_size, get_rank def load_state_with_same_shape(model, weights): print(weights.keys()) model_state = model.stat...
13,615
34.643979
108
py
VIBUS
VIBUS-master/pretrain/lib/dataset.py
from abc import ABC from pathlib import Path from collections import defaultdict import random import numpy as np from enum import Enum import open3d as o3d import torch import math from torch.utils.data import Dataset, DataLoader import MinkowskiEngine as ME from plyfile import PlyData import lib.transforms as t f...
21,381
32.305296
136
py
VIBUS
VIBUS-master/pretrain/lib/layers.py
import torch import torch.nn as nn from MinkowskiEngine import MinkowskiGlobalPooling, MinkowskiBroadcastAddition, MinkowskiBroadcastMultiplication class MinkowskiLayerNorm(nn.Module): def __init__(self, num_features, eps=1e-5, D=-1): super(MinkowskiLayerNorm, self).__init__() self.num_features = num_feat...
2,907
32.813953
112
py
VIBUS
VIBUS-master/pretrain/lib/distributed_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import pickle import socket import struct import subprocess import warnings import torch import torch.distributed as dist def is...
7,093
36.141361
107
py
VIBUS
VIBUS-master/pretrain/lib/solvers.py
import logging from torch.optim import SGD, Adam from torch.optim.lr_scheduler import LambdaLR, StepLR class LambdaStepLR(LambdaLR): def __init__(self, optimizer, lr_lambda, last_step=-1): super(LambdaStepLR, self).__init__(optimizer, lr_lambda, last_step) @property def last_step(self): """Use last_e...
2,625
32.240506
105
py
VIBUS
VIBUS-master/pretrain/lib/train.py
from os import write import numpy as np import logging import os.path as osp import math import scipy.ndimage import torch from torch import nn from torch.serialization import default_restore_location from tensorboardX import SummaryWriter from lib.test import test from lib.utils import checkpoint, precision_at_one, \...
14,268
41.59403
160
py
VIBUS
VIBUS-master/pretrain/lib/math_functions.py
from scipy.sparse import csr_matrix import torch class SparseMM(torch.autograd.Function): """ Sparse x dense matrix multiplication with autograd support. Implementation by Soumith Chintala: https://discuss.pytorch.org/t/ does-pytorch-support-autograd-on-sparse-matrix/6156/7 """ def forward(self, matrix...
2,060
28.028169
80
py
VIBUS
VIBUS-master/pretrain/lib/transforms.py
import random import logging import numpy as np import scipy import scipy.ndimage import scipy.interpolate import torch import math import torchvision.transforms as transforms import MinkowskiEngine as ME # A sparse tensor consists of coordinates and associated features. # You must apply augmentation to both. # In 2...
18,565
38.586354
132
py
VIBUS
VIBUS-master/SUField/setup.py
from setuptools import setup setup( name='sufield', version='0.0.1', install_requires=[ 'numpy', 'open3d', 'potpourri3d', 'torch', 'ipykernel', 'plyfile', 'scikit-learn', 'plyfile', 'matplotlib', 'scipy', 'pymeshlab', ...
327
16.263158
28
py
VIBUS
VIBUS-master/SUField/sufield/spec_cluster.py
""" spec_cluster.py """ from copy import deepcopy from typing import Tuple import numpy as np import open3d as o3d import potpourri3d as pp3d import torch from IPython import embed from plyfile import PlyData from sklearn.cluster import KMeans from .downsample import downsample from .utils import Timer, plydata_to_ar...
6,176
40.18
105
py
VIBUS
VIBUS-master/instance_segmentation/config.py
import argparse def str2opt(arg): assert arg in ['SGD', 'Adam'] return arg def str2scheduler(arg): assert arg in ['StepLR', 'PolyLR', 'ExpLR', 'SquaredLR'] return arg def str2bool(v): return v.lower() in ('true', '1') def str2list(l): return [int(i) for i in l.split(',')] def add_argum...
11,969
57.676471
185
py
VIBUS
VIBUS-master/instance_segmentation/new.py
import logging import os import time import random import numpy as np import torch from torch import nn import torch.nn.functional as F import torch.distributed as dist import torch.multiprocessing as mp from lib.solvers import initialize_optimizer, initialize_scheduler from lib.utils import save_predictions from lib...
18,445
37.26971
272
py
VIBUS
VIBUS-master/instance_segmentation/models/resnet.py
import torch.nn as nn import MinkowskiEngine as ME from models.model import Model from models.modules.common import ConvType, NormType, get_norm, conv, sum_pool from models.modules.resnet_block import BasicBlock, Bottleneck class ResNetBase(Model): BLOCK = None LAYERS = () INIT_DIM = 64 PLANES = (64, 128, 2...
5,352
23.668203
94
py
VIBUS
VIBUS-master/instance_segmentation/models/conditional_random_fields.py
import torch import torch.nn as nn from torch.autograd import Variable from MinkowskiEngine import SparseTensor, MinkowskiConvolution, MinkowskiConvolutionFunction, convert_to_int_tensor from MinkowskiEngine import convert_region_type as me_convert_region_type from models.model import HighDimensionalModel from models...
6,094
35.065089
115
py
VIBUS
VIBUS-master/instance_segmentation/models/resunet.py
from models.resnet import ResNetBase, get_norm from models.modules.common import ConvType, NormType, conv, conv_tr from models.modules.resnet_block import BasicBlock, BasicBlockINBN, Bottleneck import torch.nn as nn import MinkowskiEngine as ME from MinkowskiEngine import MinkowskiReLU import MinkowskiEngine.Minkowsk...
14,938
26.767658
91
py
VIBUS
VIBUS-master/instance_segmentation/models/wrapper.py
import random from torch.nn import Module from MinkowskiEngine import SparseTensor class Wrapper(Module): """ Wrapper for the segmentation networks. """ OUT_PIXEL_DIST = -1 def __init__(self, NetClass, in_nchannel, out_nchannel, config): super(Wrapper, self).__init__() self.initialize_filter(NetCl...
950
29.677419
80
py
VIBUS
VIBUS-master/instance_segmentation/models/modules/senet_block.py
import torch.nn as nn import MinkowskiEngine as ME from models.modules.common import ConvType, NormType from models.modules.resnet_block import BasicBlock, Bottleneck class SELayer(nn.Module): def __init__(self, channel, reduction=16, D=-1): # Global coords does not require coords_key super(SELayer, self...
3,081
22
90
py
VIBUS
VIBUS-master/instance_segmentation/models/modules/common.py
import collections from enum import Enum import torch.nn as nn import MinkowskiEngine as ME class NormType(Enum): BATCH_NORM = 0 INSTANCE_NORM = 1 INSTANCE_BATCH_NORM = 2 def get_norm(norm_type, n_channels, D, bn_momentum=0.1): if norm_type == NormType.BATCH_NORM: return ME.MinkowskiBatchNorm(n_channels...
6,971
30.835616
97
py
VIBUS
VIBUS-master/instance_segmentation/models/modules/resnet_block.py
import torch.nn as nn from models.modules.common import ConvType, NormType, get_norm, conv from MinkowskiEngine import MinkowskiReLU class BasicBlockBase(nn.Module): expansion = 1 NORM_TYPE = NormType.BATCH_NORM def __init__(self, inplanes, planes, stride=1, ...
3,174
23.423077
100
py
VIBUS
VIBUS-master/instance_segmentation/lib/test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import shutil import tempfile import warnings import numpy as np import torch import torch.nn as nn from sklearn.m...
10,346
37.040441
134
py
VIBUS
VIBUS-master/instance_segmentation/lib/dataloader.py
import torch import math from torch.utils.data.sampler import Sampler import torch.distributed as dist class InfSampler(Sampler): """Samples elements randomly, without replacement. Arguments: data_source (Dataset): dataset to sample from """ def __init__(self, data_source, shuffle=Fals...
2,233
28.012987
80
py
VIBUS
VIBUS-master/instance_segmentation/lib/utils.py
import json import logging import os import errno import time import numpy as np import torch from lib.pc_utils import colorize_pointcloud, save_point_cloud from lib.distributed_utils import get_world_size, get_rank def load_state_with_same_shape(model, weights): print(weights.keys()) model_state = model.stat...
13,615
34.643979
108
py
VIBUS
VIBUS-master/instance_segmentation/lib/dataset.py
from abc import ABC from pathlib import Path from collections import defaultdict import random import numpy as np from enum import Enum import torch from torch.utils.data import Dataset, DataLoader import MinkowskiEngine as ME from plyfile import PlyData import lib.transforms as t from lib.dataloader import InfSamp...
18,442
32.111311
155
py
VIBUS
VIBUS-master/instance_segmentation/lib/layers.py
import torch import torch.nn as nn from MinkowskiEngine import MinkowskiGlobalPooling, MinkowskiBroadcastAddition, MinkowskiBroadcastMultiplication class MinkowskiLayerNorm(nn.Module): def __init__(self, num_features, eps=1e-5, D=-1): super(MinkowskiLayerNorm, self).__init__() self.num_features = num_feat...
2,907
32.813953
112
py
VIBUS
VIBUS-master/instance_segmentation/lib/distributed_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import pickle import socket import struct import subprocess import warnings import torch import torch.distributed as dist def is...
7,103
36.193717
107
py
VIBUS
VIBUS-master/instance_segmentation/lib/solvers.py
import logging from torch.optim import SGD, Adam from torch.optim.lr_scheduler import LambdaLR, StepLR class LambdaStepLR(LambdaLR): def __init__(self, optimizer, lr_lambda, last_step=-1): super(LambdaStepLR, self).__init__(optimizer, lr_lambda, last_step) @property def last_step(self): """Use last_e...
2,625
32.240506
105
py
VIBUS
VIBUS-master/instance_segmentation/lib/train.py
import numpy as np import logging import os.path as osp import torch from torch import nn from torch.serialization import default_restore_location from torch.utils.tensorboard import SummaryWriter from lib.test import test from lib.utils import checkpoint, precision_at_one, \ Timer, AverageMeter, get_prediction, ...
9,990
39.28629
158
py
VIBUS
VIBUS-master/instance_segmentation/lib/math_functions.py
from scipy.sparse import csr_matrix import torch class SparseMM(torch.autograd.Function): """ Sparse x dense matrix multiplication with autograd support. Implementation by Soumith Chintala: https://discuss.pytorch.org/t/ does-pytorch-support-autograd-on-sparse-matrix/6156/7 """ def forward(self, matrix...
2,060
28.028169
80
py
VIBUS
VIBUS-master/instance_segmentation/lib/transforms.py
import random import logging import numpy as np import scipy import scipy.ndimage import scipy.interpolate import torch import math import MinkowskiEngine as ME # A sparse tensor consists of coordinates and associated features. # You must apply augmentation to both. # In 2D, flip, shear, scale, and rotation of image...
13,470
37.933526
132
py
VIBUS
VIBUS-master/instance_segmentation/lib/datasets/stanford_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import sys import numpy as np from collections import defaultdict from scipy import spatial import torch from plyfi...
8,676
31.992395
92
py
VIBUS
VIBUS-master/instance_segmentation/lib/datasets/stanford.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import sys import numpy as np from collections import defaultdict from scipy import spatial import torch from plyfi...
8,649
32.141762
92
py
VIBUS
VIBUS-master/instance_segmentation/lib/bfs/bfs.py
import os import torch import numpy as np from torch.autograd import Function import argparse #from lib.datasets.scannet.datagen.export_ids_per_vertex import read_segmentation, write_triangle_mesh #from lib.utils.io import read_triangle_mesh, create_color_palette, write_triangle_mesh #from lib.utils.scannet_benchmark_u...
5,867
36.139241
133
py
VIBUS
VIBUS-master/instance_segmentation/lib/bfs/ops/setup.py
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension import os _ext_src_root = os.path.abspath(os.environ['CONDA_PREFIX']) setup( name='PG_OP', ext_modules=[ CUDAExtension('PG_OP', [ 'src/bfs_cluster.cpp', 'src/bfs_cluster_kernel.cu', ...
594
30.315789
83
py
VIBUS
VIBUS-master/semantic_segmentation/fit.py
from argparse import ArgumentParser import os from plyfile import PlyData import numpy as np from sufield.fit import mixture_filter, BetaDistribution, GammaDistribution from sufield.spec_cluster import geodesic_correlation_matrix, angular_correlation_matrix, spectral_cluster from sufield.utils import plydata_to_array, ...
3,429
47.309859
109
py
VIBUS
VIBUS-master/semantic_segmentation/config.py
import argparse def str2opt(arg): assert arg in ['SGD', 'Adam'] return arg def str2scheduler(arg): assert arg in ['StepLR', 'PolyLR', 'ExpLR', 'SquaredLR'] return arg def str2bool(v): return v.lower() in ('true', '1') def str2list(l): return [int(i) for i in l.split(',')] def add_argument_group(na...
12,283
43.34657
102
py
VIBUS
VIBUS-master/semantic_segmentation/new.py
import logging import os import time import random import numpy as np import torch from torch import nn import torch.nn.functional as F import torch.distributed as dist import torch.multiprocessing as mp from lib.solvers import initialize_optimizer, initialize_scheduler from lib.utils import save_predictions from lib...
41,150
38.416667
199
py
VIBUS
VIBUS-master/semantic_segmentation/models/resnet.py
import torch.nn as nn import MinkowskiEngine as ME from models.model import Model from models.modules.common import ConvType, NormType, get_norm, conv, sum_pool from models.modules.resnet_block import BasicBlock, Bottleneck class ResNetBase(Model): BLOCK = None LAYERS = () INIT_DIM = 64 PLANES = (64, 128, 2...
5,352
23.668203
94
py
VIBUS
VIBUS-master/semantic_segmentation/models/conditional_random_fields.py
import torch import torch.nn as nn from torch.autograd import Variable from MinkowskiEngine import SparseTensor, MinkowskiConvolution, MinkowskiConvolutionFunction, convert_to_int_tensor from MinkowskiEngine import convert_region_type as me_convert_region_type from models.model import HighDimensionalModel from models...
6,094
35.065089
115
py
VIBUS
VIBUS-master/semantic_segmentation/models/resunet.py
from models.resnet import ResNetBase, get_norm from models.modules.common import ConvType, NormType, conv, conv_tr from models.modules.resnet_block import BasicBlock, BasicBlockINBN, Bottleneck import torch.nn as nn import MinkowskiEngine as ME from MinkowskiEngine import MinkowskiReLU import MinkowskiEngine.Minkowsk...
14,938
26.767658
91
py
VIBUS
VIBUS-master/semantic_segmentation/models/wrapper.py
import random from torch.nn import Module from MinkowskiEngine import SparseTensor class Wrapper(Module): """ Wrapper for the segmentation networks. """ OUT_PIXEL_DIST = -1 def __init__(self, NetClass, in_nchannel, out_nchannel, config): super(Wrapper, self).__init__() self.initialize_filter(NetCl...
950
29.677419
80
py
VIBUS
VIBUS-master/semantic_segmentation/models/modules/senet_block.py
import torch.nn as nn import MinkowskiEngine as ME from models.modules.common import ConvType, NormType from models.modules.resnet_block import BasicBlock, Bottleneck class SELayer(nn.Module): def __init__(self, channel, reduction=16, D=-1): # Global coords does not require coords_key super(SELayer, self...
3,081
22
90
py
VIBUS
VIBUS-master/semantic_segmentation/models/modules/common.py
import collections from enum import Enum import torch.nn as nn import MinkowskiEngine as ME class NormType(Enum): BATCH_NORM = 0 INSTANCE_NORM = 1 INSTANCE_BATCH_NORM = 2 def get_norm(norm_type, n_channels, D, bn_momentum=0.1): if norm_type == NormType.BATCH_NORM: return ME.MinkowskiBatchNorm(n_channels...
6,971
30.835616
97
py
VIBUS
VIBUS-master/semantic_segmentation/models/modules/resnet_block.py
import torch.nn as nn from models.modules.common import ConvType, NormType, get_norm, conv from MinkowskiEngine import MinkowskiReLU class BasicBlockBase(nn.Module): expansion = 1 NORM_TYPE = NormType.BATCH_NORM def __init__(self, inplanes, planes, stride=1, ...
3,174
23.423077
100
py
VIBUS
VIBUS-master/semantic_segmentation/lib/test.py
import logging import os import shutil import tempfile import warnings import numpy as np import torch import torch.nn as nn from sklearn.metrics import average_precision_score from sklearn.preprocessing import label_binarize from lib.utils import Timer, AverageMeter, precision_at_one, fast_hist, per_class_iu, \ ...
7,561
38.385417
136
py
VIBUS
VIBUS-master/semantic_segmentation/lib/dataloader.py
import torch import math from torch.utils.data.sampler import Sampler import torch.distributed as dist class InfSampler(Sampler): """Samples elements randomly, without replacement. Arguments: data_source (Dataset): dataset to sample from """ def __init__(self, data_source, shuffle=Fals...
2,233
28.012987
80
py
VIBUS
VIBUS-master/semantic_segmentation/lib/utils.py
import json import logging import os import errno import time import numpy as np import torch from lib.pc_utils import colorize_pointcloud, save_point_cloud from lib.distributed_utils import get_world_size, get_rank def load_state_with_same_shape(model, weights): print(weights.keys()) model_state = model.stat...
13,615
34.643979
108
py
VIBUS
VIBUS-master/semantic_segmentation/lib/dataset.py
from abc import ABC from pathlib import Path from collections import defaultdict import random import numpy as np from enum import Enum import torch from torch.utils.data import Dataset, DataLoader import MinkowskiEngine as ME from plyfile import PlyData import lib.transforms as t from lib.dataloader import InfSamp...
16,526
31.791667
155
py
VIBUS
VIBUS-master/semantic_segmentation/lib/layers.py
import torch import torch.nn as nn from MinkowskiEngine import MinkowskiGlobalPooling, MinkowskiBroadcastAddition, MinkowskiBroadcastMultiplication class MinkowskiLayerNorm(nn.Module): def __init__(self, num_features, eps=1e-5, D=-1): super(MinkowskiLayerNorm, self).__init__() self.num_features = num_feat...
2,907
32.813953
112
py
VIBUS
VIBUS-master/semantic_segmentation/lib/distributed_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import pickle import socket import struct import subprocess import warnings import torch import torch.distributed as dist def is...
7,103
36.193717
107
py
VIBUS
VIBUS-master/semantic_segmentation/lib/solvers.py
import logging from torch.optim import SGD, Adam from torch.optim.lr_scheduler import LambdaLR, StepLR class LambdaStepLR(LambdaLR): def __init__(self, optimizer, lr_lambda, last_step=-1): super(LambdaStepLR, self).__init__(optimizer, lr_lambda, last_step) @property def last_step(self): """Use last_e...
2,625
32.240506
105
py
VIBUS
VIBUS-master/semantic_segmentation/lib/train.py
import numpy as np import logging import os.path as osp import torch from torch import nn from torch.serialization import default_restore_location from torch.utils.tensorboard import SummaryWriter from lib.test import test from lib.utils import checkpoint, precision_at_one, \ Timer, AverageMeter, get_prediction, ...
9,928
39.198381
158
py
VIBUS
VIBUS-master/semantic_segmentation/lib/math_functions.py
from scipy.sparse import csr_matrix import torch class SparseMM(torch.autograd.Function): """ Sparse x dense matrix multiplication with autograd support. Implementation by Soumith Chintala: https://discuss.pytorch.org/t/ does-pytorch-support-autograd-on-sparse-matrix/6156/7 """ def forward(self, matrix...
2,060
28.028169
80
py
VIBUS
VIBUS-master/semantic_segmentation/lib/transforms.py
import random import logging import numpy as np import scipy import scipy.ndimage import scipy.interpolate import torch import math import MinkowskiEngine as ME # A sparse tensor consists of coordinates and associated features. # You must apply augmentation to both. # In 2D, flip, shear, scale, and rotation of image...
13,353
37.707246
132
py
VIBUS
VIBUS-master/semantic_segmentation/lib/datasets/stanford_test.py
import logging import os import sys import numpy as np from collections import defaultdict from scipy import spatial from plyfile import PlyData from lib.utils import read_txt, fast_hist, per_class_iu from lib.dataset import VoxelizationDataset, DatasetPhase, str2datasetphase_type, cache import lib.transforms as t c...
7,164
32.481308
100
py
VIBUS
VIBUS-master/semantic_segmentation/lib/datasets/stanford.py
import logging import os import sys import numpy as np from collections import defaultdict from scipy import spatial from plyfile import PlyData from lib.utils import read_txt, fast_hist, per_class_iu from lib.dataset import VoxelizationDataset, DatasetPhase, str2datasetphase_type, cache import lib.transforms as t c...
7,151
32.420561
100
py
DGCN
DGCN-master/load_semigcn_data.py
import sys import networkx as nx import scipy.sparse as sp import pickle as pkl import numpy as np def load_data_gcn(dataset_str): names = ['x', 'y', 'tx', 'ty', 'allx', 'ally', 'graph'] objects = [] for i in range(len(names)): with open("data/gcn/ind.{}.{}".format(dataset_str, names[i]), 'rb') as ...
2,830
32.702381
81
py
DGCN
DGCN-master/run_exps_diff_layers.py
import torch import torch.nn as nn import torch.optim as optim from utils import load_data, process_graph_data from utils import package_mxl, adj_rw_norm from utils import sparse_mx_to_torch_sparse_tensor from utils import ResultRecorder from model import GCN, GCNBias, SGC, ResGCN, GCNII, APPNP from layers import Gra...
16,007
41.802139
138
py
DGCN
DGCN-master/data_loader.py
import numpy as np import scipy.sparse as sp from utils import sparse_mx_to_torch_sparse_tensor import multiprocessing as mp import time import os import torch class DataLoader(object): def __init__(self, adj_mat, train_nodes, valid_nodes, test_nodes, device): self.adj_mat = adj_mat self.train_nod...
2,827
37.739726
81
py
DGCN
DGCN-master/utils.py
import numpy as np import json import copy import scipy.sparse as sp from sklearn.preprocessing import StandardScaler from sklearn.metrics import f1_score import torch import torch.nn as nn import torch.nn.functional as F """ Load data """ def load_data(prefix, normalize=True): adj_full = sp.load_npz('./data/{}/a...
3,645
33.074766
94
py
DGCN
DGCN-master/model.py
import torch import torch.nn as nn import math ######################################################### ######################################################### ######################################################### class GCN(nn.Module): def __init__(self, n_feat, n_hid, n_classes, n_layers, dropout, criteri...
10,225
33.200669
79
py
DGCN
DGCN-master/layers.py
import torch import torch.nn as nn from initialization_utils import uniform, zeros class GraphConv(nn.Module): def __init__(self, n_in, n_out, bias=False): super(GraphConv, self).__init__() self.n_in = n_in self.n_out = n_out self.linear = nn.Linear(n_in, n_out, bias=bias) ...
1,887
29.451613
74
py
DGCN
DGCN-master/initialization_utils.py
import math import torch def uniform(size, tensor): if tensor is not None: bound = 1.0 / math.sqrt(size) tensor.data.uniform_(-bound, bound) def kaiming_uniform(tensor, fan, a): if tensor is not None: bound = math.sqrt(6 / ((1 + a**2) * fan)) tensor.data.uniform_(-bound, bou...
855
21.526316
69
py
restarted-hb
restarted-hb-main/problem/classification_mnist.py
from typing import Sequence import functools import flax.linen as nn import jax import jax.numpy as jnp import numpy as np from sklearn.model_selection import train_test_split from torchvision.datasets import MNIST jax.config.update("jax_enable_x64", True) N_TARGETS = 10 SCALE_IMAGE = 255 TRAIN_MAX = 60000 # load ...
4,005
33.534483
117
py
restarted-hb
restarted-hb-main/problem/rosenbrock.py
import jax import jax.numpy as jnp import functools class Problem: def __init__(self, a, b, d, x0): self.a = a self.b = b self.d = d self.x0 = jnp.ones(d) * x0 def inner_func(self, x): return jnp.concatenate((self.a - x[:-1], jnp.sqrt(self.b) * (x[1:] - x[:-1] ** 2))) ...
517
22.545455
91
py
restarted-hb
restarted-hb-main/problem/ae_mnist.py
from typing import Sequence import functools import flax.linen as nn import jax import jax.numpy as jnp import numpy as np from sklearn.model_selection import train_test_split from torchvision.datasets import MNIST jax.config.update("jax_enable_x64", True) SCALE_IMAGE = 255 # load data # from https://jax.readthedo...
3,056
32.228261
114
py
restarted-hb
restarted-hb-main/problem/mf_movielens.py
import functools import jax import jax.numpy as jnp import numpy as np from scipy.sparse import coo_matrix from scipy.sparse.linalg import svds import pandas as pd jax.config.update("jax_enable_x64", True) def df_to_sparse_matrix(df: pd.DataFrame): for cid in ("user", "item"): vs = df[cid].unique() ...
4,140
35.324561
116
py
restarted-hb
restarted-hb-main/optimizer/internal.py
import jax class Oracle: def __init__(self, instance): self.__func = instance.func self.count = dict.fromkeys(["eval", "grad"], 0) def reset_count(self): self.count = dict.fromkeys(self.count.keys(), 0) def func(self, x, counted=True): if counted: self.count["...
645
23.846154
56
py
restarted-hb
restarted-hb-main/optimizer/method.py
import jax.numpy as jnp import jax from . import internal class Base: def __init__(self): self.iter = 0 @property def recorded_params(self): return {} @property def solutions(self): return {} def update(self, oracle: internal.Oracle): pass class GradientDes...
13,712
28.364026
88
py
restarted-hb
restarted-hb-main/optimizer/__init__.py
import jax from .main import SmoothNonconvexMin jax.config.update("jax_enable_x64", True) jax.config.update("jax_debug_nans", True)
134
18.285714
41
py
jlonevae
jlonevae-main/disentanglement_lib/disentanglement_lib/evaluation/abstract_reasoning/relational_layers.py
# coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. 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 # # Un...
7,576
38.259067
80
py
jlonevae
jlonevae-main/disentanglement_lib/disentanglement_lib/evaluation/abstract_reasoning/models.py
# coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. 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 # # Un...
11,089
35.60066
80
py
jlonevae
jlonevae-main/disentanglement_lib/disentanglement_lib/evaluation/abstract_reasoning/relational_layers_test.py
# coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. 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 # # Un...
4,868
39.575
80
py
jlonevae
jlonevae-main/exampleScripts/createLatentJacobianImages_naturalImages.py
#!/usr/bin/env python3 import numpy as np import scipy.io as sio from jlonevae_lib.architecture.load_model import load_model import jlonevae_lib.architecture.vae_jacobian as vj import torch import PIL.Image from pathlib import Path import os.path import glob import argparse parser = argparse.ArgumentParser(description...
7,179
43.04908
125
py
jlonevae
jlonevae-main/exampleScripts/smallEvaluation.py
# coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # Copyright 2021 Travers Rhodes. 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 # ...
6,930
37.72067
104
py
jlonevae
jlonevae-main/jlonevae_lib/baseline_lib/evaluate/evaluation.py
# coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # Copyright 2021 Travers Rhodes. 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 # ...
7,226
38.708791
104
py
jlonevae
jlonevae-main/jlonevae_lib/architecture/load_model.py
import pickle import torch from jlonevae_lib.architecture.vae import ConvVAE def load_model(model_folder_path, device="cpu"): with open(model_folder_path + "/model_type.txt", "r") as f: model_type = f.readline().strip() with open(model_folder_path + "/model_args.p", "rb") as f: kwargs = pickle.lo...
634
34.277778
118
py
jlonevae
jlonevae-main/jlonevae_lib/architecture/vae.py
import torch from torch import nn, optim from torch.nn import functional as F import math class VAE(nn.Module): def __init__(self, beta=1.0): super(VAE, self).__init__() def reparameterize(self, mu, logvar): std = torch.exp(0.5*logvar) eps = torch.randn((mu.shape[0], mu.shape[1]), ...
8,103
45.045455
202
py
jlonevae
jlonevae-main/jlonevae_lib/architecture/vae_jacobian.py
import numpy as np import torch from torch import nn, optim from torch.nn import functional as F import math import os from opt_einsum import contract def compute_generator_jacobian_image_optimized(model, embedding, epsilon_scale = 0.001, device="cpu"): raw_jacobian = compute_generator_jacobian_optimized(model, e...
6,064
44.94697
102
py
jlonevae
jlonevae-main/jlonevae_lib/architecture/save_model.py
import pickle import os import torch # Save the model in an custom-code-readable way def save_conv_vae(convvae, model_folder_path): kwargs = {"latent_dim": convvae.latent_dim, "im_side_len": convvae.im_side_len, "im_channels": convvae.im_channels, "emb_conv_layers_channels...
1,355
49.222222
83
py
jlonevae
jlonevae-main/jlonevae_lib/train/train_jlonevae_models.py
__doc__ = """ This code was taken and modified from https://github.com/AIcrowd/neurips2019_disentanglement_challenge_starter_kit """ # Note: _we_ don't use tensorflow, but we call data-loading code that does # trying so hard to mute tensorflow warnings... # https://stackoverflow.com/questions/57539273/disable-tensorfl...
7,721
40.074468
124
py
jlonevae
jlonevae-main/jlonevae_lib/train/train_jlonevae_without_disentanglement_lib.py
# If you want to train a jlonevae model directly # without using disentanglement_lib, you can do so by using this file. # For our paper, this is the implementation we use for the naturalImage results # for which we do not have ground-truth factors of variation. import datetime import torch import glob import math impor...
6,267
43.140845
131
py
jlonevae
jlonevae-main/jlonevae_lib/train/loss_function.py
import torch TESTING=False # Set to True to run a bunch of extra asserts # Reconstruction + KL divergence losses summed over all pixels and batch def vae_loss_function(recon_x, x, mu, logvar, beta): # To make the units work properly, this should be equal to # the log reconstruction probability, which is #...
2,464
46.403846
102
py
jlonevae
jlonevae-main/jlonevae_lib/train/jlonevae_trainer.py
# if you want to train without using the disentanglement_lib infrastructure # you can train using this file. # This file's train method is very, very similar to # jlonevae_lib/train/train_jlonevae_models.py's train method # This is just an object-oriented version of that more script-based version # this file's train m...
4,103
47.282353
114
py
jlonevae
jlonevae-main/jlonevae_lib/evaluate/evaluate_helper.py
# coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # Copyright 2021 Travers Rhodes. 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 # ...
9,585
44.866029
128
py
jlonevae
jlonevae-main/jlonevae_lib/evaluate/evaluation.py
# coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # Copyright 2021 Travers Rhodes. 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 # ...
7,569
37.820513
104
py
jlonevae
jlonevae-main/jlonevae_lib/utils/utils_pytorch.py
from copy import deepcopy import os from collections import namedtuple import numpy as np import torch from torch.jit import trace # ------ Data Loading ------ from torch.utils.data.dataset import Dataset from torch.utils.data.dataloader import DataLoader import os if 'DISENTANGLEMENT_LIB_DATA' not in os.environ: ...
10,443
34.164983
157
py
jlonevae
jlonevae-main/jlonevae_lib/utils/pytorch_npz_dataset.py
#### If, instead of using disentanglement_lib's infrastructure #### you want to just train on a npz file of data directly #### (eg: no ground-truth factors, like for natural images) #### you can use this dataloader import torch import numpy as np # maybe I'm just being overly fancy here, # but this is basically just a...
1,740
43.641026
90
py
jlonevae
jlonevae-main/experimentScripts/visualizations/createLatentJacobianImages_naturalImages.py
#!/usr/bin/env python3 import numpy as np import scipy.io as sio from jlonevae_lib.architecture.load_model import load_model import jlonevae_lib.architecture.vae_jacobian as vj import torch import PIL.Image from pathlib import Path import os.path import glob import argparse parser = argparse.ArgumentParser(description...
7,120
42.95679
125
py
jlonevae
jlonevae-main/experimentScripts/visualizations/analyticNaturalImages/01a-trainAnalyticModel.py
#!/usr/bin/env python3 import numpy as np import datetime import glob import sys sys.path.append("../../..") # include base dir from jlonevae_lib.utils.pytorch_npz_dataset import PytorchNpzDataset from sklearn.decomposition import FastICA, PCA import torch.utils from pathlib import Path import os.path import argpar...
3,290
42.302632
174
py
jlonevae
jlonevae-main/experimentScripts/train_linear/trainLinearModels_naturalImages.py
#!/usr/bin/env python3 import numpy as np import datetime import glob from jlonevae_lib.utils.pytorch_npz_dataset import PytorchNpzDataset from sklearn.decomposition import FastICA, PCA import torch.utils from pathlib import Path import os.path import argparse parser = argparse.ArgumentParser(description='Train ICA ...
3,201
42.863014
174
py
SimpleDG
SimpleDG-main/ddp_training/main.py
import os import argparse import math import numpy as np import torch import torch.nn as nn import torch.optim as optim import torch.distributed as dist import torch.utils.data as data from pprint import pprint from model import build_model from dataset import build_dataset from augment import FMixup from transform imp...
10,265
30.29878
138
py
SimpleDG
SimpleDG-main/ddp_training/test.py
import os import csv import json import argparse from glob import glob from collections import OrderedDict import torch from torch.utils import data from tqdm.auto import tqdm from model import build_model from dataset import NICOTestDataset from transform import TestTransform from utils import load_config_from_file ...
4,230
32.054688
84
py
SimpleDG
SimpleDG-main/ddp_training/transform.py
from random import random, randint import numpy as np from PIL import Image, ImageFilter from torchvision import transforms import torchvision.transforms.functional as F from timm.data import RandAugment, rand_augment_ops def fourier_domain_adaptation(img, target_img, beta): img = np.squeeze(img) target_img =...
5,159
31.45283
86
py