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 |
|---|---|---|---|---|---|---|
IGEV | IGEV-main/IGEV-MVS/datasets/tanks.py | from torch.utils.data import Dataset
from datasets.data_io import *
import os
import numpy as np
import cv2
from PIL import Image
class MVSDataset(Dataset):
def __init__(self, datapath, n_views=7, img_wh=(1920, 1024), split='intermediate'):
self.levels = 4
self.datapath = datapath
self.img_... | 5,974 | 37.057325 | 106 | py |
IGEV | IGEV-main/IGEV-MVS/datasets/blendedmvs.py | from torch.utils.data import Dataset
from datasets.data_io import *
import os
import numpy as np
import cv2
from PIL import Image
from torchvision import transforms as T
import random
class MVSDataset(Dataset):
def __init__(self, datapath, listfile, split, nviews, img_wh=(768, 576), robust_train=True):
... | 8,489 | 39.817308 | 113 | py |
IGEV | IGEV-main/IGEV-MVS/datasets/dtu_yao.py | from torch.utils.data import Dataset
import numpy as np
import os
from PIL import Image
from datasets.data_io import *
import cv2
import random
from torchvision import transforms
class MVSDataset(Dataset):
def __init__(self, datapath, listfile, mode, nviews, robust_train = False):
super(MVSDataset, self).... | 8,874 | 36.447257 | 115 | py |
IGEV | IGEV-main/IGEV-Stereo/evaluate_stereo.py | from __future__ import print_function, division
import sys
sys.path.append('core')
import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import argparse
import time
import logging
import numpy as np
import torch
from tqdm import tqdm
from igev_stereo import IGEVStereo, autocast
import stereo_datasets as datasets
from ... | 10,694 | 39.358491 | 201 | py |
IGEV | IGEV-main/IGEV-Stereo/demo_imgs.py | import sys
sys.path.append('core')
DEVICE = 'cuda'
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import argparse
import glob
import numpy as np
import torch
from tqdm import tqdm
from pathlib import Path
from igev_stereo import IGEVStereo
from utils.utils import InputPadder
from PIL import Image
from matplotlib im... | 4,564 | 50.292135 | 159 | py |
IGEV | IGEV-main/IGEV-Stereo/save_disp.py | import sys
sys.path.append('core')
import argparse
import glob
import numpy as np
import torch
from tqdm import tqdm
from pathlib import Path
from igev_stereo import IGEVStereo
from utils.utils import InputPadder
from PIL import Image
from matplotlib import pyplot as plt
import os
import skimage.io
import cv2
DEVICE... | 4,052 | 47.831325 | 153 | py |
IGEV | IGEV-main/IGEV-Stereo/demo_video.py | import sys
sys.path.append('core')
import cv2
import numpy as np
import glob
from pathlib import Path
from tqdm import tqdm
import torch
from PIL import Image
from igev_stereo import IGEVStereo
import os
import argparse
from utils.utils import InputPadder
torch.backends.cudnn.benchmark = True
half_precision = True
DE... | 4,553 | 46.4375 | 168 | py |
IGEV | IGEV-main/IGEV-Stereo/train_stereo.py | from __future__ import print_function, division
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0, 1'
import argparse
import logging
import numpy as np
from pathlib import Path
from tqdm import tqdm
from torch.utils.tensorboard import SummaryWriter
import torch
import torch.nn as nn
import torch.optim as optim
from cor... | 10,683 | 41.907631 | 153 | py |
IGEV | IGEV-main/IGEV-Stereo/core/stereo_datasets.py | import numpy as np
import torch
import torch.utils.data as data
import torch.nn.functional as F
import logging
import os
import re
import copy
import math
import random
from pathlib import Path
from glob import glob
import os.path as osp
from core.utils import frame_utils
from core.utils.augmentor import FlowAugmentor... | 15,502 | 45.695783 | 200 | py |
IGEV | IGEV-main/IGEV-Stereo/core/update.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from opt_einsum import contract
class FlowHead(nn.Module):
def __init__(self, input_dim=128, hidden_dim=256, output_dim=2):
super(FlowHead, self).__init__()
self.conv1 = nn.Conv2d(input_dim, hidden_dim, 3, padding=1)
self.co... | 5,687 | 38.776224 | 107 | py |
IGEV | IGEV-main/IGEV-Stereo/core/submodule.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class BasicConv(nn.Module):
def __init__(self, in_channels, out_channels, deconv=False, is_3d=False, bn=True, relu=True, **kwargs):
super(BasicConv, self).__init__()
self.relu = relu
self.use_bn = bn
... | 8,910 | 34.221344 | 151 | py |
IGEV | IGEV-main/IGEV-Stereo/core/extractor.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from core.submodule import *
import timm
class ResidualBlock(nn.Module):
def __init__(self, in_planes, planes, norm_fn='group', stride=1):
super(ResidualBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_... | 12,837 | 34.366391 | 102 | py |
IGEV | IGEV-main/IGEV-Stereo/core/geometry.py | import torch
import torch.nn.functional as F
from core.utils.utils import bilinear_sampler
class Combined_Geo_Encoding_Volume:
def __init__(self, init_fmap1, init_fmap2, geo_volume, num_levels=2, radius=4):
self.num_levels = num_levels
self.radius = radius
self.geo_volume_pyramid = []
... | 2,564 | 36.173913 | 100 | py |
IGEV | IGEV-main/IGEV-Stereo/core/igev_stereo.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from core.update import BasicMultiUpdateBlock
from core.extractor import MultiBasicEncoder, Feature
from core.geometry import Combined_Geo_Encoding_Volume
from core.submodule import *
import time
try:
autocast = torch.cuda.amp.autocast
except:
... | 10,349 | 45.621622 | 173 | py |
IGEV | IGEV-main/IGEV-Stereo/core/utils/utils.py | import torch
import torch.nn.functional as F
import numpy as np
from scipy import interpolate
class InputPadder:
""" Pads images such that dimensions are divisible by 8 """
def __init__(self, dims, mode='sintel', divis_by=8):
self.ht, self.wd = dims[-2:]
pad_ht = (((self.ht // divis_by) + 1) *... | 3,222 | 32.226804 | 89 | py |
IGEV | IGEV-main/IGEV-Stereo/core/utils/augmentor.py | import numpy as np
import random
import warnings
import os
import time
from glob import glob
from skimage import color, io
from PIL import Image
import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
import torch
from torchvision.transforms import ColorJitter, functional, Compose
import torch.nn.functional as F
... | 12,411 | 37.7875 | 141 | py |
rl-mapping | rl-mapping-master/main.py | import argparse
import os
import random
from envs import MappingEnvironment, LocalISM, RangeISM
from model import CNNActorCritic, MLPActorCritic, ResNetActorCritic, LinearActorCritic
from distributions import Multinomial
import torch
from torch import nn
from torch.autograd import Variable
import numpy as np
parser... | 8,245 | 35.486726 | 118 | py |
rl-mapping | rl-mapping-master/distributions.py | r"""
The ``distributions`` package contains parameterizable probability distributions
and sampling functions.
Policy gradient methods can be implemented using the
:meth:`~torch.distributions.Distribution.log_prob` method, when the probability
density function is differentiable with respect to its parameters. A basic
m... | 5,853 | 29.175258 | 99 | py |
rl-mapping | rl-mapping-master/model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from math import floor
import IPython as ipy
class LinearActorCritic(nn.Module):
def __init__(self, H_in=100, nc=2, na=4):
super(LinearActorCritic, self).__init__()
self.H_in = H_in
self.... | 4,148 | 28.635714 | 79 | py |
vexcl | vexcl-master/docs/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# VexCL documentation build configuration file, created by
# sphinx-quickstart on Fri Mar 11 13:53:31 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# auto... | 9,667 | 30.802632 | 80 | py |
MGMN | MGMN-main/src/ged_train.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# ************************************
# @Time : 2019/3/3 22:34
# @Author : Xiang Ling
# @Lab : nesa.zju.edu.cn
# @File : ged_train.py
# ************************************
import numpy as np
import os
import torch
import torch.nn.functional as functional
fr... | 11,120 | 49.55 | 186 | py |
MGMN | MGMN-main/src/cfg_train.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# ************************************
# @Time : 2019/7/3 22:34
# @Author : Xiang Ling
# @Lab : nesa.zju.edu.cn
# @File : cfg_train.py
# ************************************
import numpy as np
import os
import torch
from datetime import datetime
from sklearn... | 8,114 | 46.45614 | 168 | py |
MGMN | MGMN-main/src/model/DenseGraphMatching.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# ************************************
# @Time : 2019/3/4 17:16
# @Author : Xiang Ling
# @Lab : nesa.zju.edu.cn
# @File : DenseGraphMatching.py
# ************************************
import torch
import torch.nn as nn
import torch.nn.functional as functional... | 13,447 | 50.13308 | 165 | py |
MGMN | MGMN-main/src/model/DenseGGNN.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# ************************************
# @Time : 2019/3/3 17:16
# @Author : Xiang Ling
# @Lab : nesa.zju.edu.cn
# @File : DenseGGNN.py
# ************************************
import torch
import torch.nn as nn
from torch_geometric.nn.conv.gated_graph_conv im... | 1,024 | 29.147059 | 85 | py |
papa | papa-main/transformers/src/transformers/papa_modules.py | import torch
from torch import nn
import json
import os
from .modeling_utils import ModuleUtilsMixin
import numpy as np
from .activations import ACT2FN
class FreezeExtractPoller(nn.Module):
def __init__(self, config):
super().__init__()
self.dense_across_layers = nn.Linear((config.num_hidden_layers... | 4,804 | 39.041667 | 120 | py |
papa | papa-main/transformers/src/transformers/modeling_utils.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors, Facebook AI Research authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the L... | 117,076 | 46.747553 | 189 | py |
papa | papa-main/transformers/src/transformers/models/deberta/modeling_deberta.py | # coding=utf-8
# Copyright 2020 Microsoft and the Hugging Face Inc. team.
#
# 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 require... | 61,716 | 39.523309 | 181 | py |
papa | papa-main/transformers/src/transformers/models/roberta/modeling_roberta.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... | 72,547 | 42.888687 | 198 | py |
papa | papa-main/transformers/src/transformers/models/bert/modeling_bert.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... | 83,962 | 41.903935 | 202 | py |
papa | papa-main/transformers/papa_scripts/run_papa_ner_avgs_creator.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2021 The HuggingFace Inc. team. 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/LI... | 25,813 | 40.236422 | 166 | py |
papa | papa-main/transformers/papa_scripts/run_papa_ner.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Team 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-... | 29,358 | 40.119048 | 141 | py |
papa | papa-main/transformers/papa_scripts/run_papa_glue_avgs_creator.py | # coding=utf-8
# Copyright 2021 The HuggingFace Inc. team. 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 r... | 21,837 | 42.763527 | 166 | py |
papa | papa-main/transformers/papa_scripts/run_papa_glue.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. 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/LI... | 31,178 | 42.064917 | 141 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/inference.py | import logging
import torch
from torch.utils.data import DataLoader
from tqdm import tqdm
from modelling.datasets import DataConfig, collaters_factory, datasets_factory
from modelling.configs import model_configs_factory
from modelling.models import models_factory
from utils.evaluation import evaluators_factory
from ... | 3,445 | 35.273684 | 84 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/dump_perframe_features.py | import argparse
import io
import json
import logging
import h5py
import numpy as np
import torch
from natsort import natsorted
from PIL import Image
from torch import nn
from torchvision import resnet152, transforms
class FrameEncoder(nn.Module):
def __init__(self):
super(FrameEncoder, self).__init__()
... | 3,736 | 28.425197 | 87 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/dump_perbox_features.py | import argparse
import io
import json
import logging
from typing import List
import h5py
import numpy as np
import torch
from natsort import natsorted
from PIL import Image
from torch import nn
from torchvision import transforms
from torchvision.models.detection import fasterrcnn_resnet50_fpn
from torchvision.models.d... | 5,332 | 32.968153 | 86 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/train.py | import logging
import os
import torch
from torch import optim
from torch.utils.data import DataLoader
from tqdm import tqdm
from modelling.datasets import collaters_factory, datasets_factory
from modelling.configs import model_configs_factory, DataConfig
from modelling.models import models_factory
from utils.evaluati... | 6,221 | 36.939024 | 81 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/utils/model_utils.py | import torch
def generate_square_subsequent_mask(sz: int) -> torch.Tensor:
# https://pytorch.org/docs/stable/_modules/torch/nn/modules/transformer.html#Transformer.generate_square_subsequent_mask
mask = ~(torch.triu(torch.ones(sz, sz)) == 1).transpose(0, 1)
return mask
| 284 | 34.625 | 124 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/utils/data_utils.py | from typing import List, Tuple
import ffmpeg
import numpy as np
import torch
from PIL import Image
from torchvision.transforms import ColorJitter, RandomCrop
from torchvision.transforms import functional as TF
def load_video(in_filepath: str):
"""Loads a video from a filepath."""
probe = ffmpeg.probe(in_file... | 7,854 | 32.857759 | 106 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/utils/train_inference_utils.py | import logging
from typing import Dict
import torch
from torch import nn, optim
def get_device(logger: logging.Logger):
device = torch.device("cpu")
if torch.cuda.is_available():
device = torch.device("cuda")
for i in range(torch.cuda.device_count()):
logger.warning(f"{torch.cuda.... | 2,556 | 32.207792 | 133 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/utils/evaluation.py | import numpy as np
from typing import Tuple
class EvaluatorSomething:
def __init__(
self, total_instances: int, total_classes: int, logit_names: Tuple[str]
):
self.total_instances = total_instances
self.total_classes = total_classes
self.logit_names = logit_names
self.r... | 4,514 | 31.482014 | 82 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/modelling/datasets.py | import io
import json
import math
import re
import h5py
import numpy as np
import torch
from PIL import Image
from torch.utils.data import Dataset
from torchvision.transforms import (
Compose,
Normalize,
RandomCrop,
Resize,
ToTensor,
)
from torchvision.transforms import functional as TF
from utils.... | 12,119 | 36.06422 | 95 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/modelling/models.py | from typing import Dict
import torch
from torch import nn
from torch.nn import functional as F
from utils.model_utils import generate_square_subsequent_mask
from modelling.configs import (
AppearanceModelConfig,
MultimodalModelConfig,
StltModelConfig,
)
from modelling.resnets3d import generate_model
cla... | 22,045 | 38.367857 | 88 | py |
revisiting-spatial-temporal-layouts | revisiting-spatial-temporal-layouts-main/src/modelling/resnets3d.py | from functools import partial
import torch
import torch.nn as nn
import torch.nn.functional as F
def get_inplanes():
return [64, 128, 256, 512]
def conv3x3x3(in_planes, out_planes, stride=1):
return nn.Conv3d(
in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False
)
def co... | 6,810 | 28.23176 | 86 | py |
AS_Molecule | AS_Molecule-master/base_model/sch.py | # -*- coding:utf-8 -*-
import dgl
import torch as th
import torch.nn as nn
from base_model.layers import AtomEmbedding, Interaction, ShiftSoftplus, RBFLayer
from torch.nn.modules import PairwiseDistance
class SchNetModel(nn.Module):
"""
SchNet Model from:
Schütt, Kristof, et al.
SchNet: A con... | 3,495 | 31.981132 | 81 | py |
AS_Molecule | AS_Molecule-master/base_model/train_base.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
sys.path.append('..')
from utils.funcs import *
from base_model.schmodel import... | 6,194 | 33.226519 | 91 | py |
AS_Molecule | AS_Molecule-master/base_model/layers.py | import torch as th
import numpy as np
import torch.nn as nn
import dgl.function as fn
from torch.nn import Softplus
class AtomEmbedding(nn.Module):
"""
Convert the atom(node) list to atom embeddings.
The atom with the same element share the same initial embeddding.
"""
def __init__(self, dim=128, ... | 9,374 | 32.127208 | 90 | py |
AS_Molecule | AS_Molecule-master/base_model/schmodel.py | import torch as th
import numpy as np
import torch.nn as nn
import dgl.function as fn
from torch.nn import Softplus
import dgl
#cannot first write device in model
class AtomEmbedding(nn.Module):
"""
Convert the atom(node) list to atom embeddings.
The atom with the same element share the same initial embed... | 12,889 | 30.985112 | 90 | py |
AS_Molecule | AS_Molecule-master/bayes_al/mm_sch.py | #!/usr/bin/env python
#-*- coding:utf-8 _*-
import torch as th
import numpy as np
import torch.nn as nn
import dgl.function as fn
from torch.nn import Softplus
import random
import dgl
from torch.distributions.categorical import Categorical
'''Message Masking Schnet, An attempt in one of my own models
Masking some... | 12,338 | 32.348649 | 118 | py |
AS_Molecule | AS_Molecule-master/bayes_al/msk_sch.py | #!/usr/bin/env python
#-*- coding:utf-8 _*-
import torch as th
import numpy as np
import torch.nn as nn
import dgl.function as fn
from torch.nn import Softplus
import random
import dgl
from torch.distributions.categorical import Categorical
'''Message Masking Schnet but mask message when training and testing
'''
#ca... | 12,232 | 32.332425 | 120 | py |
AS_Molecule | AS_Molecule-master/bayes_al/bald.py | import torch
import numpy as np
import time
class Bayes_sampler(object):
def __init__(self, args, total_data_num, batch_data_num, init_ids):
self.args = args
self.total_data_num = total_data_num
self.batch_data_num = batch_data_num
self.data_ids = np.delete(np.arange(self.total_dat... | 1,922 | 48.307692 | 119 | py |
AS_Molecule | AS_Molecule-master/bayes_al/mc_sch.py | import torch as th
import numpy as np
import torch.nn as nn
import dgl.function as fn
from torch.nn import Softplus
import dgl
'''Monte Carlo Dropout Schnet for active learning'''
#cannot first write device in model
class AtomEmbedding(nn.Module):
"""
Convert the atom(node) list to atom embeddings.
The at... | 10,229 | 32.762376 | 90 | py |
AS_Molecule | AS_Molecule-master/bayes_al/bayes_learn.py | import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
import time
import random
from torchnet import meter
sys.path.append('..')
from bayes_al.bald import Bayes_sampler
from config import *
from utils.funcs import *
from tensorboardX import SummaryWriter
from bayes_al.mc_sch import MC_S... | 9,316 | 36.268 | 85 | py |
AS_Molecule | AS_Molecule-master/baseline/active-learning/utils/utils.py | # Copyright 2017 Google Inc.
#
# 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 applicable law or agreed to in writing,... | 10,503 | 30.169139 | 79 | py |
AS_Molecule | AS_Molecule-master/baseline/active-learning/utils/create_data.py | # Copyright 2017 Google Inc.
#
# 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 applicable law or agreed to in writing,... | 9,340 | 31.775439 | 79 | py |
AS_Molecule | AS_Molecule-master/baseline/active-learning/utils/allconv.py | # Copyright 2017 Google Inc.
#
# 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 applicable law or agreed to in writing,... | 6,553 | 32.269036 | 80 | py |
AS_Molecule | AS_Molecule-master/baseline/active-learning/utils/small_cnn.py | # Copyright 2017 Google Inc.
#
# 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 applicable law or agreed to in writing,... | 6,485 | 31.43 | 75 | py |
AS_Molecule | AS_Molecule-master/qbc_learn/test_manager.py | from torch.multiprocessing import Manager,Queue,Process
import numpy as np
def tar(share,i):
share[i][0] = i
if __name__ == "__main__":
manager = Manager()
share = manager.list([np.zeros(4),np.zeros(4),np.zeros(4)])
ps = []
for i in range(3):
p = Process(target=tar,args=(share,i))
p... | 403 | 20.263158 | 63 | py |
AS_Molecule | AS_Molecule-master/qbc_learn/qbc.py | import torch
from utils.funcs import *
import numpy as np
from torch.utils.data import DataLoader
import torch.nn as nn
from torchnet import meter
from copy import deepcopy
import torch.multiprocessing as mp
# from torch.multiprocessing import Manager,Queue,Process,Pipe,Lock
from config import *
import time
# from base... | 21,688 | 43.173116 | 169 | py |
AS_Molecule | AS_Molecule-master/qbc_learn/test_procon.py | # import torch.multiprocessing as mp
from utils.funcs import Molecule
import numpy as np
from torch.multiprocessing import Process, Queue, Lock
import torch
import random
import time
import os
class TestClass():
def __init__(self,tensor,arr=np.zeros([3])):
self.t = tensor
self.p = arr
# Producer f... | 2,932 | 29.873684 | 91 | py |
AS_Molecule | AS_Molecule-master/qbc_learn/model.py | import torch as th
import numpy as np
import torch.nn as nn
import dgl.function as fn
from torch.nn import Softplus
import dgl
#cannot first write device in model
class AtomEmbedding(nn.Module):
"""
Convert the atom(node) list to atom embeddings.
The atom with the same element share the same initial embedd... | 9,267 | 31.069204 | 90 | py |
AS_Molecule | AS_Molecule-master/geo_al/k_center.py | import numpy as np
import torch
import multiprocessing as mp
import time
from utils.funcs import *
import random
import math
class K_center(object):
def __init__(self, args, total_data_num, batch_data_num, init_ids):
self.args = args
self.total_data_num = total_data_num
self.batch_data_num... | 4,262 | 36.069565 | 121 | py |
AS_Molecule | AS_Molecule-master/geo_al/embedding_model.py | import torch as th
import torch.nn as nn
import numpy as np
import dgl
import dgl.function as fn
from torch.nn import Softplus
#cannot first write device in model
class AtomEmbedding(nn.Module):
"""
Convert the atom(node) list to atom embeddings.
The atom with the same element share the same initial embed... | 10,204 | 31.603834 | 90 | py |
AS_Molecule | AS_Molecule-master/geo_al/k_center_cifar10.py | import torch.nn as nn
import torch
from geo_al.k_center import K_center
from config import *
from utils.funcs import *
from torch.utils.data import DataLoader
import torch.utils as utils
import time
import random
from torchnet import meter
from tensorboardX import SummaryWriter
from geo_al.cnn import *
class CNN_Cifa... | 11,901 | 39.209459 | 136 | py |
AS_Molecule | AS_Molecule-master/geo_al/geo_learn.py | import torch
import torch.nn as nn
from geo_al.embedding_model import SchEmbedding
from geo_al.k_center import K_center
from config import *
from utils.funcs import *
from torch.utils.data import DataLoader
import time
import random
from torchnet import meter
from tensorboardX import SummaryWriter
# K_center AL
#load ... | 9,014 | 36.252066 | 85 | py |
AS_Molecule | AS_Molecule-master/geo_al/dist_test.py | import numpy as np
import time
from multiprocessing import Pool
import torch
from geo_al.k_center import K_center
if __name__ == "__main__":
l = torch.randn(50000, 320)
g = torch.randn(50000, 320)
l = l.cuda(0)
g = g.cuda(0)
m = torch.zeros(l.size(0))
time0 = time.time()
for i in range(l.si... | 427 | 22.777778 | 58 | py |
AS_Molecule | AS_Molecule-master/single_model_al/wsl_al.py | import torch
import torch.nn as nn
from torch.utils.data import DataLoader
import time
import random
import numpy as np
import sys
from tensorboardX import SummaryWriter
sys.path.append('..')
from pre_training.wsch import WSchnet, Semi_Schnet
from single_model_al.sampler import AL_sampler, Inferencer, check_point_test... | 10,450 | 37.707407 | 156 | py |
AS_Molecule | AS_Molecule-master/single_model_al/sampler.py | import torch
import numpy as np
import random
import torch.nn as nn
import time
from copy import deepcopy
import math
from torch.utils.data import DataLoader
from torchnet import meter
from torch.optim import Adam
import pandas as pd
import sys
import ot
import torch.nn.functional as F
import copy
sys.path.append('..'... | 48,770 | 40.018503 | 177 | py |
AS_Molecule | AS_Molecule-master/single_model_al/run_al.py | import torch
import torch.nn as nn
from torch.utils.data import DataLoader
import time
import random
import numpy as np
import sys
from tensorboardX import SummaryWriter
sys.path.append('..')
from bayes_al.mc_sch import MC_SchNetModel
from bayes_al.mm_sch import MM_SchNetModel
from base_model.schmodel import SchNetMod... | 9,062 | 35.10757 | 117 | py |
AS_Molecule | AS_Molecule-master/utils/funcs.py | import networkx as nx
from rdkit import Chem
import numpy as np
import torch
import dgl
from torch.utils.data import Dataset
import pickle
from torch.nn import DataParallel
import os
import torch.utils.data as data
import random
import time
from sklearn.cluster import KMeans
# import torch.multiprocessing as mp
# torch... | 25,279 | 32.932886 | 241 | py |
AS_Molecule | AS_Molecule-master/utils/prepare_data.py | import pickle
import torch
''' Please download and prepare dataset files under the following instructions
1.download
'''
| 130 | 20.833333 | 82 | py |
AS_Molecule | AS_Molecule-master/utils/data_utils.py | # -*- coding:utf-8 -*-
"""Example dataloader of Tencent Alchemy Dataset
https://alchemy.tencent.com/
"""
import os
import zipfile
import os.path as osp
from rdkit import Chem
from rdkit.Chem import ChemicalFeatures
from rdkit import RDConfig
import dgl
from dgl.data.utils import download
import torch
from collections i... | 9,990 | 35.068592 | 78 | py |
AS_Molecule | AS_Molecule-master/utils/pre/time_pre.py | import dgl
import networkx as nx
import numpy as np
import time
import pickle
# import torch.multiprocessing as _mp
from torch.multiprocessing import Pool, Manager, Process, Queue
import sys
import rdkit.Chem as Chem
import torch
from copy import deepcopy
# from utils.funcs import Molecule
torch.multiprocessing.set_sha... | 6,546 | 29.03211 | 241 | py |
AS_Molecule | AS_Molecule-master/utils/pre/opv_savedata.py | from utils.funcs import Molecule
import numpy as np
from multiprocessing import Manager, Process
import torch
import dgl
import sys
sys.path.append('..')
from utils.funcs import MoleDataset2
from config import Global_Config as Config
config = Config()
def get_mol(data):
pos, atoms, edges, smi, prop, dists = data... | 1,776 | 24.385714 | 66 | py |
AS_Molecule | AS_Molecule-master/utils/pre/op_savedata.py | import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.getcwd(), "../..")))
from utils.funcs import Molecule
import numpy as np
from multiprocessing import Manager, Process
import torch
import dgl
from utils.funcs import MoleDataset
from config import Global_Config as Config
config = Config()
def get_m... | 1,855 | 25.140845 | 76 | py |
AS_Molecule | AS_Molecule-master/utils/pre/parallelload.py | from utils.funcs import Molecule
import numpy as np
from multiprocessing import Manager, Process
import torch
import dgl
import sys
from utils.funcs import MoleDataset2
from config import Global_Config as Config
config = Config()
def get_mol(data):
pos, atoms, edges, smi, prop, dists = data
return Molecule(po... | 1,753 | 24.794118 | 66 | py |
AS_Molecule | AS_Molecule-master/utils/data_clustering/smilarity_sch.py | #!/usr/bin/env python
#-*- coding:utf-8 _*-
import pickle
from utils import *
import rdkit
from rdkit import Chem
from rdkit import DataStructs
import numpy as np
from rdkit.Chem import rdMolDescriptors
import pandas as pd
from sklearn.decomposition import PCA
from sklearn.preprocessing import MinMaxScaler
from torch.... | 3,186 | 27.972727 | 86 | py |
AS_Molecule | AS_Molecule-master/utils/data_clustering/smilarity.py | import pickle
from utils import *
import rdkit
from rdkit import Chem
from rdkit import DataStructs
import numpy as np
from rdkit.Chem import rdMolDescriptors
from config import Global_Config
import pandas as pd
from sklearn.decomposition import PCA
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplo... | 5,780 | 30.939227 | 93 | py |
AS_Molecule | AS_Molecule-master/pre_training/train_part_msg.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import random
import pickle
sys.path.append('..')
from utils.funcs import *
from base_model.s... | 6,253 | 34.737143 | 171 | py |
AS_Molecule | AS_Molecule-master/pre_training/graph_ae.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
import torch.nn.functional as F
import ot
sys.path.append('..')
from utils.func... | 14,972 | 37.992188 | 279 | py |
AS_Molecule | AS_Molecule-master/pre_training/ot_pretrain.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
import ot
import torch.nn.functional as F
sys.path.append('..')
from utils.func... | 8,961 | 35.430894 | 144 | py |
AS_Molecule | AS_Molecule-master/pre_training/train_part.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import random
import pickle
sys.path.append('..')
from utils.funcs import *
from base_model.s... | 6,692 | 35.57377 | 171 | py |
AS_Molecule | AS_Molecule-master/pre_training/w_ptr.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
sys.path.append('..')
from utils.funcs import *
from base_model.schmodel impor... | 8,188 | 35.887387 | 144 | py |
AS_Molecule | AS_Molecule-master/pre_training/sch_embeddings.py | import torch as th
import torch.nn as nn
import numpy as np
import dgl
import dgl.function as fn
from torch.nn import Softplus
#cannot first write device in model
class AtomEmbedding(nn.Module):
"""
Convert the atom(node) list to atom embeddings.
The atom with the same element share the same initial embedd... | 9,876 | 30.758842 | 90 | py |
AS_Molecule | AS_Molecule-master/pre_training/w_ptr_r.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
import torch.nn.functional as F
import ot
sys.path.append('..')
from utils.fun... | 11,913 | 37.934641 | 279 | py |
AS_Molecule | AS_Molecule-master/pre_training/wsch.py | #!/usr/bin/env python
#-*- coding:utf-8 _*-
'''Schnet in a weakly supervised manner
1. node level pre_training with node attributes Masking
2. graph level pre_training with contrasive loss or clustering loss
3. weakly supervised learning on specific properties
'''
import torch as th
import torch.nn as n... | 30,468 | 30.50879 | 123 | py |
AS_Molecule | AS_Molecule-master/pre_training/ot_unsupervised.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
import torch.nn.functional as F
import ot
sys.path.append('..')
from utils.func... | 12,711 | 36.498525 | 279 | py |
AS_Molecule | AS_Molecule-master/pre_training/train_part_cls.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import random
import pickle
sys.path.append('..')
from utils.funcs import *
from base_model.s... | 6,312 | 34.466292 | 171 | py |
AS_Molecule | AS_Molecule-master/pre_training/non_ptrain_cls.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import random
import pickle
sys.path.append('..')
from utils.funcs import *
from base_model.s... | 9,243 | 35.25098 | 91 | py |
AS_Molecule | AS_Molecule-master/pre_training/train_part_transfer.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
import torch.nn.functional as F
import ot
sys.path.append('..')
from utils.fun... | 10,862 | 36.588235 | 279 | py |
AS_Molecule | AS_Molecule-master/pre_training/node_ptr.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
sys.path.append('..')
from utils.funcs import *
from base_model.schmodel import... | 6,778 | 33.065327 | 94 | py |
AS_Molecule | AS_Molecule-master/pre_training/semi_supervised_learn.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
import torch.nn.functional as F
import ot
sys.path.append('..')
from utils.fun... | 13,797 | 36.906593 | 323 | py |
AS_Molecule | AS_Molecule-master/pre_training/w_ptr_part.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
sys.path.append('..')
from utils.funcs import *
from base_model.schmodel impor... | 8,188 | 35.887387 | 144 | py |
AS_Molecule | AS_Molecule-master/pre_training/cls_ptr.py | #!usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import torch
import sys
import torch.nn as nn
from torch.utils.data import DataLoader
from torchnet import meter
from tensorboardX import SummaryWriter
import time
import pickle
sys.path.append('..')
from utils.funcs import *
from base_model.schmodel import... | 8,259 | 34.757576 | 144 | py |
AS_Molecule | AS_Molecule-master/rd_learn/rd_al.py | from utils.funcs import *
import numpy as np
import random
import torch.nn as nn
from torchnet import meter
from torch.utils.data import DataLoader
from tensorboardX import SummaryWriter
from config import *
from base_model.sch import SchNetModel
from copy import deepcopy
def random_data_sampler(MaDataset, label_rate... | 7,055 | 33.930693 | 79 | py |
NEDMP | NEDMP-main/structure_generalization.py | import argparse
import numpy as np
import pickle as pkl
from collections import defaultdict
import torch
from torch.utils import data
from src.utils.dataset import graph_dataset
from src.utils.utils import aligning, L1_error
from src.model.model import NodeGNN, NEDMP
def eval(model, loader):
# Eval
model.eva... | 3,845 | 38.244898 | 146 | py |
NEDMP | NEDMP-main/train.py | import time
import argparse
import numpy as np
from tqdm import tqdm
import pickle as pkl
from functools import partial
import torch
from torch import optim
from torch.utils.data import DataLoader
from src.utils.dataset import graph_dataset
from src.utils.utils import aligning, L1_error
from src.model.model import No... | 8,214 | 39.668317 | 197 | py |
NEDMP | NEDMP-main/src/utils/utils.py | # -*- encoding: utf-8 -*-
'''
@File : utils.py
@Time : 2021/04/01 17:04:49
@Author : Fei gao
@Contact : feig@mail.bnu.edu.cn
BNU, Beijing, China
'''
import scipy.sparse as sp
import numpy as np
import torch
import networkx as nx
def line_graph(edge_index, N, E):
"""generate the line graph from edg... | 2,315 | 27.592593 | 105 | py |
NEDMP | NEDMP-main/src/utils/dataset.py | # -*- encoding: utf-8 -*-
'''
@File : dataset.py
@Time : 2021/03/30 20:38:14
@Author : Fei gao
@Contact : feig@mail.bnu.edu.cn
BNU, Beijing, China
'''
from numpy.lib.arraysetops import isin
from scipy import sparse
from scipy.sparse import block_diag
import networkx as nx
import scipy.sparse as sp
impor... | 4,747 | 34.699248 | 107 | py |
NEDMP | NEDMP-main/src/model/model.py | from numpy import NaN
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_scatter import scatter
class baseModule(nn.Module):
def __init__(self):
super(baseModule, self).__init__()
def loss_function(self, p, q, reduce="mean"):
logits = p
labels = q
lo... | 18,399 | 37.983051 | 143 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.