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 |
|---|---|---|---|---|---|---|
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/vqa.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import os
import collections
import torch
import torch.nn as nn
from torch.utils.data.dataloader import DataLoader
from tqdm import tqdm
from param import args
from pretrain.qa_answer_table import load_lxmert_qa
from tasks.vqa_model import VQAModel
from tasks.vqa_data imp... | 7,794 | 35.255814 | 98 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/nlvr2_data.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import json
import numpy as np
from torch.utils.data import Dataset
from param import args
from utils import load_obj_tsv
# Load part of the dataset for fast checking.
# Notice that here is the number of images instead of the number of data,
# which means all related dat... | 4,922 | 30.158228 | 110 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/gqa_data_patches.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import json
import numpy as np
import torch
from torch.utils.data import Dataset
from src.param import args
from src.utils import load_obj_tsv, load_patches
# Load part of the dataset for fast checking.
# Notice that here is the number of images instead of the number of ... | 6,458 | 30.661765 | 119 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/refcoco_data.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import json
import random
import numpy as np
import torch
from torch.utils.data import Dataset
import cv2
from tqdm import tqdm
from src import eval_utils
from src.param import args
from src.utils import load_obj_tsv, load_spatial_data
from src.box_utils import create_mask... | 10,947 | 35.013158 | 113 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/vqahat_data.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import json
import numpy as np
import torch
from torch.utils.data import Dataset
from src.param import args
from src.utils import load_spatial_data
# Load part of the dataset for fast checking.
# Notice that here is the number of images instead of the number of data,
# w... | 6,874 | 31.276995 | 119 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/mscoco_retrieval.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import os
import collections
import numpy as np
import gc
import torch
from tqdm import tqdm
import torch.nn as nn
from torch.utils.data.dataloader import DataLoader
from src.param import args
from src.pretrain.qa_answer_table import load_lxmert_qa
from src.tasks.mscoco_re... | 11,733 | 38.508418 | 193 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/nlvr2.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import os
import collections
from tqdm import tqdm
import torch
import torch.nn as nn
from torch.utils.data.dataloader import DataLoader
from param import args
from tasks.nlvr2_model import NLVR2Model
from tasks.nlvr2_data import NLVR2Dataset, NLVR2TorchDataset, NLVR2Eval... | 6,387 | 33.907104 | 98 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/nlvr2_model.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import torch.nn as nn
from lxrt.modeling import GeLU, BertLayerNorm
from lxrt.entry import LXRTEncoder
from param import args
class NLVR2Model(nn.Module):
def __init__(self):
super().__init__()
self.lxrt_encoder = LXRTEncoder(
args,
... | 1,773 | 30.678571 | 94 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/gqa.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import os
import collections
import gc
import torch
from tqdm import tqdm
import torch.nn as nn
from torch.utils.data.dataloader import DataLoader
from src.param import args
from src.pretrain.qa_answer_table import load_lxmert_qa
from src.tasks.gqa_model import GQAModel
i... | 11,068 | 36.64966 | 220 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/refcocog.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import os
import collections
import gc
import torch
from tqdm import tqdm
import torch.nn as nn
from torch.utils.data.dataloader import DataLoader
from src import eval_utils
from src.param import args
from src.pretrain.qa_answer_table import load_lxmert_qa
from src.tasks.... | 10,637 | 37.683636 | 191 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/refcocoplus_model.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import torch.nn as nn
from src.param import args
from src.lxrt.entry import LXRTEncoder
from src.lxrt.modeling_capsbert import BertLayerNorm, GeLU
# Max length including <bos> and <eos>
MAX_GQA_LENGTH = 20
class RefCOCOplusModel(nn.Module):
def __init__(self):
... | 1,301 | 26.125 | 72 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/refcoco_model.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import torch.nn as nn
from src.param import args
from src.lxrt.entry import LXRTEncoder
from src.lxrt.modeling_capsbert import BertLayerNorm, GeLU, MLP, BertReferExpHead
# Max length including <bos> and <eos>
MAX_GQA_LENGTH = 20
class RefCOCOModel(nn.Module):
def __... | 2,368 | 33.838235 | 132 | py |
WSG-VQA-VLTransformers | WSG-VQA-VLTransformers-main/src/tasks/refcocog_data.py | # coding=utf-8
# Copyleft 2019 project LXRT.
import json
import random
import numpy as np
import torch
from torch.utils.data import Dataset
from src import eval_utils
from src.param import args
from src.utils import load_obj_tsv, load_spatial_data
# Load part of the dataset for fast checking.
# Notice that here is ... | 8,008 | 33.080851 | 113 | py |
gcnwmmse | gcnwmmse-main/datawriter.py | """
Author:
Lukas Schynol
lukasschy96@gmail.com
"""
import os
import time
import torch
import numpy as np
import pandas as pd
from torch.utils.tensorboard import SummaryWriter
class SummaryWriterWrapper:
def __init__(self, summary_dir):
self.summary_dir = summary_dir
self.data_path = os.path.joi... | 8,913 | 38.973094 | 112 | py |
gcnwmmse | gcnwmmse-main/main.py | import sys
import os
import comm.mathutil as util
import torch
import comm.trainer as trainer
import comm.channel
import comm.algorithm as algo
DATADIR = os.path.join(os.getcwd(), "data")
RUN_NAME = "gcnwmmse_example"
MODEL_NAME = "GCNWMMSE"
TESTDATA_PATH = os.path.join(DATADIR, "testdata", "exampledata_3BSs_9UEs")
... | 3,134 | 31.65625 | 119 | py |
gcnwmmse | gcnwmmse-main/comm/mathutil.py | import time
import torch
import torch.nn.functional as F
import torch.nn as nn
import matplotlib.pyplot as plt
def randcn(*args, **kwargs):
"""
Use similarly to torch.randn, but returns complex normal and normalized by 1/sqrt(2).
"""
re = torch.randn(*args, **kwargs) / torch.tensor(2).sqrt()
im = ... | 6,590 | 30.84058 | 111 | py |
gcnwmmse | gcnwmmse-main/comm/network.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import comm.mathutil as util
class GCN(nn.Module):
def __init__(self,
num_features, # list of length num_layers + 1, (in_feat, .., out_feat)
num_layers,
num_operators, # number of shift matrices... | 6,539 | 42.026316 | 120 | py |
gcnwmmse | gcnwmmse-main/comm/algorithm.py | """
For WMMSE, see Shi et al. - 2011 - An Iteratively Weighted MMSE Approach to Distributed Sum-Utility Maximization for a MIMO Interfering Broadcast Channel
"""
import math
import torch
import torch.optim as optim
import torch.nn as nn
import torch.nn.functional as F
import comm.mathutil as util
import comm.channel a... | 40,624 | 45.641791 | 224 | py |
gcnwmmse | gcnwmmse-main/comm/channel.py | import random
from math import sqrt, pi
import torch
import comm.mathutil as util
import numpy as np
from scipy.io import loadmat
import pickle
def mimoifc_randcn(bss_dim, users_dim, assignment, batch_size=[], snr=0, weights=1, interference_ratio=1, channel_gain=1, user_noise_pow=1,
device=torch.de... | 40,531 | 44.79887 | 180 | py |
gcnwmmse | gcnwmmse-main/comm/lossfun.py | import torch
import comm.channel as channel
import comm.mathutil as util
def wrate_loss(scenario, dl_beamformers, layers="all"):
"""
Creates a normalized loss for weighted downlink rates given downlink beamformers applied in a scenario.
:param scenario:
:param dl_beamformers:
:param layers: list o... | 4,956 | 36.270677 | 124 | py |
gcnwmmse | gcnwmmse-main/comm/gcnwmmse.py | import torch
from torch import Tensor
import torch.optim as optim
import torch.nn as nn
import torch.nn.functional as F
import comm.algorithm as algo
import comm.mathutil as util
import comm.network as network
import comm.architectures as models
from typing import Optional
MIN_LAGRANGIAN = 0
REMOVE_BAD_SAMPLES = True... | 39,606 | 46.834541 | 193 | py |
gcnwmmse | gcnwmmse-main/comm/reference_wmmse_unrolls.py | """
Extended and reconfigurable implementations of IAIDNN, UWMMSE, Unfolded PGD network architectures in PyTorch. See below
for works on which the code is based.
UWMMSE: Chowdhury et al. - 2020 - Unfolding WMMSE using Graph Neural Networks for Efficient Power Allocation
Unfolded PGD: Pellaco et al. - 2020 - Iterative A... | 39,896 | 42.038835 | 160 | py |
gcnwmmse | gcnwmmse-main/comm/trainer.py | import os
import math
import random
import torch
import torch.optim as optim
import torch.nn as nn
import comm.channel as channel
import comm.algorithm as algo
import comm.lossfun as lossfun
import comm.architectures as models
import numpy as np
import matplotlib.pyplot as plt
import datawriter
import time
class Trai... | 52,943 | 48.158774 | 190 | py |
otfusion | otfusion-master/main.py | import parameters
from data import get_dataloader
import routines
import baseline
import wasserstein_ensemble
import os
import utils
import numpy as np
import sys
import torch
PATH_TO_CIFAR = "./cifar/"
sys.path.append(PATH_TO_CIFAR)
import train as cifar_train
from tensorboardX import SummaryWriter
if __name__ == '... | 13,333 | 43.595318 | 225 | py |
otfusion | otfusion-master/routines.py | import os
import torch
import torch.optim as optim
import torch.nn.functional as F
from model import get_model_from_name
from data import get_dataloader
import sys
PATH_TO_CIFAR = "./cifar/"
sys.path.append(PATH_TO_CIFAR)
import train as cifar_train
import copy
def get_trained_model(args, id, random_seed, train_loader... | 16,748 | 39.751825 | 217 | py |
otfusion | otfusion-master/wasserstein_ensemble.py | import ot
import torch
import numpy as np
import routines
from model import get_model_from_name
import utils
from ground_metric import GroundMetric
import math
import sys
import compute_activations
def cost_matrix(x, y, p=2):
"Returns the matrix of $|x_i-y_j|^p$."
x_col = x.unsqueeze(1)
y_lin = y.unsqueeze... | 41,429 | 45.187291 | 153 | py |
otfusion | otfusion-master/ground_metric.py | import torch
from utils import isnan
class GroundMetric:
"""
Ground Metric object for Wasserstein computations:
"""
def __init__(self, params, not_squared = False):
self.params = params
self.ground_metric_type = params.ground_metric
self.ground_metric_normalize = params.gr... | 7,514 | 40.065574 | 111 | py |
otfusion | otfusion-master/compute_activations.py | import parameters
from data import get_dataloader
import routines
import baseline
import wasserstein_ensemble
import os
import utils as myutils
import sys
PATH_TO_CIFAR = "./cifar/"
sys.path.append(PATH_TO_CIFAR)
import train as cifar_train
import hyperparameters.vgg11_cifar10_baseline as vgg_hyperparams
import torch
... | 18,575 | 40.74382 | 170 | py |
otfusion | otfusion-master/ensemble_cifar_models.py | import os
import utils as myutils
import sys
PATH_TO_CIFAR = "./cifar/"
sys.path.append(PATH_TO_CIFAR)
import train as cifar_train
import hyperparameters.vgg11_cifar10_baseline as vgg_hyperparams
import wasserstein_ensemble
import baseline
import parameters
import torch
ensemble_root_dir = "./cifar_models/"
# ensemble_... | 1,823 | 31.571429 | 124 | py |
otfusion | otfusion-master/model.py | import torch.nn as nn
import torch.nn.functional as F
import sys
PATH_TO_CIFAR = "./cifar/"
sys.path.append(PATH_TO_CIFAR)
import train as cifar_train
def get_model_from_name(args, idx=-1):
if idx != -1 and idx == (args.num_models - 1):
# only passes for the second model
width_ratio = args.width_ra... | 7,608 | 37.236181 | 148 | py |
otfusion | otfusion-master/data.py | import torch
import torchvision
import sys
PATH_TO_CIFAR = "./cifar/"
sys.path.append(PATH_TO_CIFAR)
import train as cifar_train
def get_inp_tar(dataset):
return dataset.data.view(dataset.data.shape[0], -1).float(), dataset.targets
def get_mnist_dataset(root, is_train, to_download, return_tensor=False):
mnist... | 3,987 | 42.824176 | 103 | py |
otfusion | otfusion-master/split_main.py | import parameters
from data import get_dataloader
import torch
import routines
import baseline
import wasserstein_ensemble
import os
import utils
import numpy as np
import sys
import partition
PATH_TO_CIFAR = "./cifar/"
sys.path.append(PATH_TO_CIFAR)
import train as cifar_train
from tensorboardX import SummaryWriter
... | 11,889 | 46.370518 | 197 | py |
otfusion | otfusion-master/baseline.py | import torch
import torch.nn.functional as F
from model import get_model_from_name
import routines
def get_avg_parameters(networks, weights=None):
avg_pars = []
for par_group in zip(*[net.parameters() for net in networks]):
print([par.shape for par in par_group])
if weights is not None:
... | 4,085 | 39.455446 | 104 | py |
otfusion | otfusion-master/partition.py | import torch
import numpy as np
import data
import math
def to_dataloader(dataset, bsz):
return torch.utils.data.DataLoader(dataset, batch_size=bsz, shuffle=True)
def to_dataloader_from_tens(inp, tgt, bsz):
return to_dataloader(torch.utils.data.TensorDataset(inp, tgt), bsz)
def partition_by_labels(args, data... | 5,706 | 37.560811 | 112 | py |
otfusion | otfusion-master/mnist.py | import torch
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
import utils
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(1, 20, 5, 1)
se... | 4,972 | 38.15748 | 97 | py |
otfusion | otfusion-master/distillation_big_only.py | import torch
import numpy as np
import parameters
import utils
from data import get_dataloader
import routines
import baseline
import wasserstein_ensemble
import os
import sys
from model import get_model_from_name
import copy
import torch.optim as optim
import torch.nn as nn
import torch.nn.functional as F
def rechec... | 10,282 | 37.513109 | 118 | py |
dlib | dlib-master/tools/convert_dlib_nets_to_caffe/running_a_dlib_model_with_caffe_example.py | #!/usr/bin/env python
# This script takes the dlib lenet model trained by the
# examples/dnn_introduction_ex.cpp example program and runs it using caffe.
import caffe
import numpy as np
# Before you run this program, you need to run dnn_introduction_ex.cpp to get a
# dlib lenet model. Then you need to convert that... | 5,151 | 65.051282 | 128 | py |
SURF-GAN | SURF-GAN-main/train_surf.py | import argparse
import os
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
import torch.nn.functional as F
from torch.nn.parallel import DistributedDataParallel as DDP
from torchvision.utils import save_image
from util import setup, cleanup, sample_latent, sample_noise
from generators i... | 19,977 | 50.890909 | 303 | py |
SURF-GAN | SURF-GAN-main/render_video_semantic.py | import argparse
import math
import torch
from PIL import Image
from tqdm import tqdm
import numpy as np
import skvideo.io
import curriculums
from torch_ema import ExponentialMovingAverage
from util import sample_latent
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
def tensor_to_PIL(img):
... | 6,189 | 32.101604 | 113 | py |
SURF-GAN | SURF-GAN-main/datasets.py | """Datasets"""
import os
import torch
from torch.utils.data import DataLoader, Dataset
from torchvision import datasets
import torchvision.transforms as transforms
import torchvision
import glob
import PIL
from PIL import Image
from torch.utils.data import Dataset
class CelebA(Dataset):
"""CelebA Dataset"""
... | 2,677 | 25.514851 | 230 | py |
SURF-GAN | SURF-GAN-main/util.py | import torch
import copy
import os
import torch.distributed as dist
import torch.nn.functional as F
def setup(rank, world_size, port):
os.environ['MASTER_ADDR'] = 'localhost'
os.environ['MASTER_PORT'] = port
# initialize the process group
dist.init_process_group("gloo", rank=rank, world_size=world... | 1,365 | 24.296296 | 112 | py |
SURF-GAN | SURF-GAN-main/fid_evaluation.py | """
Contains code for logging approximate FID scores during training.
If you want to output ground-truth images from the training dataset, you can
run this file as a script.
"""
import os
import shutil
import torch
import copy
import argparse
from torchvision.utils import save_image
from pytorch_fid import fid_score
... | 4,790 | 39.948718 | 114 | py |
SURF-GAN | SURF-GAN-main/discover_semantics.py | import argparse
import math
import numpy as np
import os
import torch
import curriculums
from torch_ema import ExponentialMovingAverage
from PIL import Image
from util import sample_latent
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
if __name__ == '__main__':
parser = argparse.ArgumentP... | 3,500 | 34.363636 | 86 | py |
SURF-GAN | SURF-GAN-main/control_pose.py | import argparse
import math
import numpy as np
import os
import torch
import curriculums
from torch_ema import ExponentialMovingAverage
from tqdm import tqdm
from PIL import Image
from util import sample_latent
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
if __name__ == '__main__':
pars... | 4,818 | 31.342282 | 86 | py |
SURF-GAN | SURF-GAN-main/render_image.py | import argparse
import math
import numpy as np
import os
import torch
import curriculums
from torch_ema import ExponentialMovingAverage
from tqdm import tqdm
from PIL import Image
from util import sample_latent
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
if __name__ == '__main__':
pa... | 3,109 | 31.061856 | 88 | py |
SURF-GAN | SURF-GAN-main/render_video.py | import argparse
import math
from util import *
from PIL import Image
from tqdm import tqdm
from torch_ema import ExponentialMovingAverage
import numpy as np
import skvideo.io
import curriculums
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
def tensor_to_PIL(img):
img = img.squeeze() * 0.5... | 4,828 | 30.562092 | 113 | py |
SURF-GAN | SURF-GAN-main/generators/volumetric_rendering.py | """
Differentiable volumetric implementation used by pi-GAN generator.
"""
import time
from functools import partial
import math
import numpy as np
import torch
import torch.nn.functional as F
import matplotlib.pyplot as plt
import random
from .math_utils_torch import *
def fancy_integration(rgb_sigma, z_vals, dev... | 10,543 | 41.688259 | 205 | py |
SURF-GAN | SURF-GAN-main/generators/generator_surf.py | """Implicit generator for 3D volumes"""
import random
import torch.nn as nn
import torch
import time
import curriculums
from torch.cuda.amp import autocast
from .volumetric_rendering import *
#---------------------------------------------------------------
class ImplicitGenerator3d_SURF(nn.Module):
def __init__(... | 21,934 | 39.771375 | 131 | py |
SURF-GAN | SURF-GAN-main/generators/math_utils_torch.py | """
Utilities for geometry etc.
"""
import torch
def transform_vectors(matrix: torch.Tensor, vectors4: torch.Tensor) -> torch.Tensor:
"""
Left-multiplies MxM @ NxM. Returns NxM.
"""
res = torch.matmul(vectors4, matrix.T)
return res
def normalize_vecs(vectors: torch.Tensor) -> torch.Tensor:
... | 552 | 19.481481 | 84 | py |
SURF-GAN | SURF-GAN-main/discriminators/sgdiscriminators.py | import math
import torch
import torch.nn as nn
import curriculums
import torch.nn.functional as F
from torch.nn.utils import spectral_norm
from typing import Optional
from functools import partial
class GlobalAveragePooling(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
... | 10,288 | 31.153125 | 136 | py |
SURF-GAN | SURF-GAN-main/discriminators/discriminators.py | """Discrimators used in pi-GAN"""
import math
import torch
import torch.nn as nn
import curriculums
import torch.nn.functional as F
from discriminators.sgdiscriminators import *
class GlobalAveragePooling(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return x.mean([2... | 7,769 | 34.479452 | 136 | py |
oneDNN | oneDNN-master/doc/sphinx/conf.py | ################################################################################
# Copyright 2021-2023 Intel Corporation
#
# 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.apa... | 9,815 | 42.052632 | 203 | py |
mpmrireg | mpmrireg-main/train.py | import os
from config.global_train_config import config
import torch
if not config.using_HPC:
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = f"{config.gpu}"
if __name__ == "__main__":
if config.project == "mpmrireg":
from src.model.archs.mpmrireg import mpmrir... | 538 | 23.5 | 56 | py |
mpmrireg | mpmrireg-main/src/data/dataloaders.py | import torch.utils.data as data
import pickle as pkl
import os
import torch
import random
import numpy as np
from glob import glob
from src.model.loss import global_mutual_information
import src.model.functions as smfunction
import src.data.preprocess as pre
torch.set_default_tensor_type('torch.FloatTensor')
class m... | 3,684 | 37.385417 | 126 | py |
mpmrireg | mpmrireg-main/src/model/functions.py | import torch
import torch.nn.functional as F
import numpy as np
import pystrum.pynd.ndutils as nd
def get_reference_grid3d(img, grid_size=None):
'''
return a 5d tensor of the grid, e.g.
img --> (b, 1, h, w, z)
out --> (b, 3, h, w, z)
if grid_size is not None, then return a 3d grid with the size o... | 4,922 | 31.602649 | 117 | py |
mpmrireg | mpmrireg-main/src/model/loss.py | import torch
import torch.nn.functional as F
import pystrum.pynd.ndutils as nd
import numpy as np
def ssd(y_true, y_pred):
return F.mse_loss(y_pred, y_true)
def single_scale_dice(y_true, y_pred, eps=1e-6):
numerator = torch.sum(y_true * y_pred, axis=[1, 2, 3, 4]) * 2
denominator = torch.sum(y_true, axis=... | 8,187 | 31.109804 | 110 | py |
mpmrireg | mpmrireg-main/src/model/layers.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions.normal import Normal
class Conv3dBlock(nn.Module):
def __init__(self, inc, outc, ksize=3, stride=1, pad=1):
super(Conv3dBlock, self).__init__()
self.conv = nn.Conv3d(in_channels=inc, out_channels=outc,
... | 4,359 | 37.584071 | 104 | py |
mpmrireg | mpmrireg-main/src/model/metric.py | import torch
def dice_binary(y_true, y_pred):
pass
def centroid_distance(y_true, y_pred):
pass | 106 | 10.888889 | 38 | py |
mpmrireg | mpmrireg-main/src/model/networks/local.py | import numpy as np
import torch.nn as nn
import torch
import torch.nn.functional as F
import src.model.layers as layers
class LocalModel(nn.Module):
def __init__(self, config):
super(LocalModel, self).__init__()
self.input_shape = config.input_shape if config.patched == 0 else config.patch_size
... | 2,912 | 40.614286 | 124 | py |
mpmrireg | mpmrireg-main/src/model/archs/mpmrireg.py | from src.model.networks.local import LocalModel
from src.model import loss
import src.model.functions as smfunctions
from src.model.archs.baseArch import BaseArch
from src.data import dataloaders
import torch, os
import torch.optim as optim
from torch.utils.data import DataLoader
import pickle as pkl
import numpy as np... | 24,202 | 46.363992 | 153 | py |
mpmrireg | mpmrireg-main/src/model/archs/baseArch.py | import time, torch, sys, os
import nibabel as nib
import pickle as pkl
import numpy as np
from datetime import datetime
from glob import glob
import cv2
import matplotlib.pyplot as plt
class BaseArch(object):
def __init__(self, config):
"""basic settings"""
self.config = config
self.log_di... | 7,701 | 37.318408 | 146 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/src/nonlin_mcmc_fns.py |
import jax
import jax.numpy as jnp
from jax._src.util import partial, safe_zip, safe_map, unzip2
from jax_bayes.mcmc import SamplerState, SamplerKeys
from functools import partial
map = safe_map
zip = safe_zip
def match_dims(src, target, start_dim=1):
"""
returns an array with the data from 'src' and same ... | 4,655 | 34.007519 | 78 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/experiments/2d_exp/2d_exp.py | import os, json, time, sys
from matplotlib import pyplot as plt
from tqdm import tqdm
import jax
import jax.numpy as jnp
import jax.scipy.stats.multivariate_normal as mvn
from jax_bayes.mcmc import mala_fns
sys.path.append('../../src')
from nonlin_mcmc_fns import (
tree_split_keys,
tree_bg_select,
tree_a... | 10,361 | 30.117117 | 101 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/experiments/2d_exp/make_logprobs.py | from collections import namedtuple
import jax
import jax.numpy as jnp
Distribution = namedtuple('Distribution', ['logprob', 'sample'])
""" adapted from https://github.com/VincentStimper/normalizing-flows/blob/master/normflow/distributions.py"""
_norm = lambda x: jnp.sqrt(jnp.sum(jnp.square(x)))
def make_two_moons(... | 7,291 | 28.885246 | 123 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/experiments/cifar10/cifar10_resnet_deterministic.py | import sys
import tqdm
import haiku as hk
import tree as dm_tree
import jax
import jax.numpy as jnp
from jax.example_libraries import optimizers
from cifar10_dataloader import get_cifar10_dataset, make_continuous_iter
sys.path.append('../../src')
from custom_logging import Logger
bn_config = dict(
create_scale=T... | 4,301 | 30.632353 | 90 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/experiments/cifar10/cifar10_dataloader.py |
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
import torch; torch.manual_seed(0)
def get_cifar10_dataset(batch_size=256, eval_batch_size=256):
mean = [0.4914, 0.4822, 0.4465]
std = [0.2023, 0.1994, 0.2010]
to_numpy = lambda x: x.numpy()
train_transform = tr... | 4,314 | 25.635802 | 68 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/experiments/cifar10/cifar10_nonlin_resnet_mcmc.py | import random
import sys, datetime as dt
import numpy as np
import tqdm
import haiku as hk
import tree as dm_tree
import jax.numpy as jnp
import jax
from jax_bayes.mcmc import rms_langevin_fns, langevin_fns
sys.path.append('../../src/')
from nonlin_mcmc_fns import (
tree_split_keys,
tree_bg_select,
tree... | 10,836 | 32.971787 | 95 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/experiments/2d_exp_delmoral/nonlin_mcmc_fns_flat.py | from functools import partial
import jax
import jax.numpy as jnp
from jax._src.util import safe_zip, safe_map
map = safe_map
zip = safe_zip
def match_dims(src, target, start_dim=1):
"""
returns an array with the data from 'src' and same number of dims
as 'target' by padding with empty dimensions starting... | 3,668 | 28.829268 | 81 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/experiments/2d_exp_delmoral/2d_exp_flat_delmoral.py | import os, json, sys, time
from matplotlib import pyplot as plt
from tqdm import tqdm
import jax
import jax.numpy as jnp
import jax.scipy.stats.multivariate_normal as mvn
from mala_fns_notree import mala_fns
from nonlin_mcmc_fns_flat import (
tree_bg_select_hist,
tree_ar_select as tree_ar_select_hist,
tre... | 10,127 | 30.749216 | 101 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/experiments/2d_exp_delmoral/mala_fns_notree.py | import math, collections
import jax
import jax.numpy as jnp
from jax.example_libraries.optimizers import make_schedule
centered_uniform = \
lambda *args, **kwargs: jax.random.uniform(*args, **kwargs) - 0.5
init_distributions = dict(normal=jax.random.normal,
uniform=centered_uniform)
def... | 3,889 | 37.514851 | 96 | py |
nonlinear-mcmc-paper | nonlinear-mcmc-paper-main/experiments/2d_exp_delmoral/2d_exp_flat.py | import os, json, sys, time
from matplotlib import pyplot as plt
from tqdm import tqdm
import jax
import jax.numpy as jnp
import jax.scipy.stats.multivariate_normal as mvn
from mala_fns_notree import mala_fns
from nonlin_mcmc_fns_flat import (
tree_bg_select,
tree_ar_select,
tree_ar_propose,
tree_jump_... | 8,825 | 30.634409 | 97 | py |
pyvot | pyvot-master/utils.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import numpy as np
from PIL import Image
import warnings
import matplotlib.pyplot as plt
import matplotlib.collections as mc
import torch
COLOR_BLUE = [0.12, 0.56, 1]
COLOR_LIGHT_BLUE = ... | 11,053 | 31.511765 | 149 | py |
pyvot | pyvot-master/vot_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import torch
import torch.optim as optim
import imageio
import warnings
import utils
class Vot:
""" variational optimal transportation """
def __init__(self, data_p, data_e, lab... | 52,728 | 37.971914 | 152 | py |
pyvot | pyvot-master/demo/kmeans/kmeans_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import os
import sys
import torch
import numpy as np
import matplotlib.pyplot as plt
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from vot_torch import VWB... | 2,533 | 26.846154 | 91 | py |
pyvot | pyvot-master/demo/icp/icp_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import os
import sys
import torch
import numpy as np
from mpl_toolkits import mplot3d
import matplotlib.pyplot as plt
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__fil... | 5,718 | 30.949721 | 130 | py |
pyvot | pyvot-master/demo/sphere/sphere_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import os
import sys
import torch
import numpy as np
from mpl_toolkits import mplot3d
import matplotlib.pyplot as plt
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__fil... | 3,977 | 28.686567 | 113 | py |
pyvot | pyvot-master/demo/area/area_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
"""
===============================================================
Area Preserving Map through Optimal Transportation
=============================================================... | 3,659 | 30.016949 | 103 | py |
pyvot | pyvot-master/demo/unbalanced1/unbalanced1_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import os
import sys
import torch
import numpy as np
import matplotlib.pyplot as plt
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from vot_torch import VWB... | 4,281 | 31.938462 | 165 | py |
pyvot | pyvot-master/demo/ship/ship_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import os
import sys
import torch
import numpy as np
import matplotlib.pyplot as plt
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from vot_torch import VWB... | 1,905 | 26.623188 | 95 | py |
pyvot | pyvot-master/demo/color/color_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import os
import sys
import torch
import numpy as np
import matplotlib
from mpl_toolkits import mplot3d
matplotlib.use('Agg')
import matplotlib.pyplot as plt
sys.path.append(os.path.dirnam... | 10,577 | 35.102389 | 98 | py |
pyvot | pyvot-master/demo/rings/rings_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import numpy as np
from cycler import cycler
import matplotlib.pyplot as plt
from math import pi, cos, sin
import os
import sys
import torch
sys.path.append(os.path.dirname(os.path.dirname... | 5,058 | 27.421348 | 83 | py |
pyvot | pyvot-master/demo/error/error_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import os
import sys
import torch
import numpy as np
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from vot_torch import VWB
np.random.seed(19)
# Generate... | 1,698 | 23.985294 | 90 | py |
pyvot | pyvot-master/demo/unbalanced2/unbalanced2_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import os
import sys
import torch
import numpy as np
import matplotlib.pyplot as plt
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from vot_torch import UVW... | 1,851 | 25.457143 | 159 | py |
pyvot | pyvot-master/demo/regVOT/potential_pytorch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
"""
===========================================
Regularized Wasserstein Means
===========================================
This demo shows that regularizing the centroids by using c... | 4,548 | 35.98374 | 113 | py |
pyvot | pyvot-master/demo/regVOT/transform_torch.py | # PyVot Python Variational Optimal Transportation
# Author: Liang Mi <icemiliang@gmail.com>
# Date: April 28th 2020
# Licence: MIT
import os
import sys
import time
import torch
import numpy as np
import sklearn.datasets
import matplotlib.pyplot as plt
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__... | 4,530 | 34.960317 | 111 | py |
kaggle_yt8m | kaggle_yt8m-master/n12_pepe_zoo.py | from keras.models import Model
from keras.layers import Input, Dense, BatchNormalization, Dropout, merge
from keras.layers.advanced_activations import LeakyReLU, PReLU, ELU
from keras.utils.visualize_util import plot
from keras.regularizers import l2
from keras.utils.visualize_util import plot
from keras.optimizers imp... | 10,091 | 24.484848 | 73 | py |
kaggle_yt8m | kaggle_yt8m-master/n11_train.py | from n12_pepe_zoo import build_mod2, build_mod3, build_mod4, build_mod5, build_mod6, build_mod7, \
build_mod8, build_mod9, build_mod10, build_mod11, build_mod12, build_mod13
from keras.optimizers import sgd, adam
import numpy as np
from time import time
from n00_localconfig import FOLDER, FAST, WPATH
import glob
im... | 5,741 | 32.383721 | 111 | py |
kaggle_yt8m | kaggle_yt8m-master/n00_utils.py | from keras.layers import merge
from keras.layers.core import Lambda
from keras.models import Model
import tensorflow as tf
import numpy as np
import random
import os
from n00_localconfig import *
from sklearn.metrics import average_precision_score
from numba import jit
from time import time
from multiprocessing impo... | 3,913 | 26.758865 | 118 | py |
NNDM-safe-control | NNDM-safe-control-master/src/dynamics_model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class FC(nn.Module):
def __init__(self, num_layer, input_dim, hidden_dim, output_dim):
super(FC, self).__init__()
self.num_layer = num_layer
self.fc = nn.ModuleList()
self.fc.append(nn.Linear(input_dim, hidden_dim))
... | 621 | 33.555556 | 69 | py |
NNDM-safe-control | NNDM-safe-control-master/src/utils.py | import torch
import numpy as np
from dynamics_model import FC
import sys
sys.path.append('../')
def convert(prefix, model_prefix, num_layer, input_dim, hidden_dim, output_dim):
model = FC(num_layer=num_layer, input_dim = input_dim, hidden_dim = hidden_dim, output_dim = output_dim)
PATH = '../model/' + pre... | 4,208 | 40.673267 | 121 | py |
NNDM-safe-control | NNDM-safe-control-master/src/train_model_ensemble.py | import torch
import torchvision
import torchvision.transforms as transforms
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
import sys, os
from dynamics_dataset import GymDynamicsDataset
from dynamics_model import FC
sys.path.append('../')
import matplotlib.pyplot a... | 2,742 | 32.048193 | 90 | py |
NNDM-safe-control | NNDM-safe-control-master/src/train_nn_dynamics.py | import torch
import torchvision
import torchvision.transforms as transforms
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
import sys, os
from dynamics_dataset import GymDynamicsDataset
from dynamics_model import FC
sys.path.append('../')
import matplotlib.pyplot a... | 5,858 | 28.00495 | 104 | py |
ARSaliency | ARSaliency-main/models/VQSal/main_test_baseline.py | ## --------------------------------------------------------------------------
## Saliency in Augmented Reality
## Huiyu Duan, Wei Shen, Xiongkuo Min, Danyang Tu, Jing Li, and Guangtao Zhai
## ACM International Conference on Multimedia (ACM MM 2022)
## --------------------------------------------------------------------... | 8,038 | 35.707763 | 165 | py |
ARSaliency | ARSaliency-main/models/VQSal/main.py | import argparse, os, sys, datetime, glob, importlib
from omegaconf import OmegaConf
import numpy as np
from PIL import Image
import torch
import torchvision
from torch.utils.data import random_split, DataLoader, Dataset
import pytorch_lightning as pl
from pytorch_lightning import seed_everything
from pytorch_lightning.... | 21,114 | 35.217839 | 138 | py |
ARSaliency | ARSaliency-main/models/VQSal/main_test_ar.py | ## --------------------------------------------------------------------------
## Saliency in Augmented Reality
## Huiyu Duan, Wei Shen, Xiongkuo Min, Danyang Tu, Jing Li, and Guangtao Zhai
## ACM International Conference on Multimedia (ACM MM 2022)
## --------------------------------------------------------------------... | 8,383 | 36.097345 | 165 | py |
ARSaliency | ARSaliency-main/models/VQSal/setup.py | from setuptools import setup, find_packages
setup(
name='taming-transformers',
version='0.0.1',
description='Taming Transformers for High-Resolution Image Synthesis',
packages=find_packages(),
install_requires=[
'torch',
'numpy',
'tqdm',
],
)
| 292 | 19.928571 | 74 | py |
ARSaliency | ARSaliency-main/models/VQSal/main_transfer.py | ## --------------------------------------------------------------------------
## Saliency in Augmented Reality
## Huiyu Duan, Wei Shen, Xiongkuo Min, Danyang Tu, Jing Li, and Guangtao Zhai
## ACM International Conference on Multimedia (ACM MM 2022)
## --------------------------------------------------------------------... | 21,592 | 35.413153 | 138 | py |
ARSaliency | ARSaliency-main/models/VQSal/saliency_measures.py | ## --------------------------------------------------------------------------
## Saliency in Augmented Reality
## Huiyu Duan, Wei Shen, Xiongkuo Min, Danyang Tu, Jing Li, and Guangtao Zhai
## ACM International Conference on Multimedia (ACM MM 2022)
## --------------------------------------------------------------------... | 12,422 | 36.194611 | 133 | py |
ARSaliency | ARSaliency-main/models/VQSal/main_test.py | ## --------------------------------------------------------------------------
## Saliency in Augmented Reality
## Huiyu Duan, Wei Shen, Xiongkuo Min, Danyang Tu, Jing Li, and Guangtao Zhai
## ACM International Conference on Multimedia (ACM MM 2022)
## --------------------------------------------------------------------... | 7,290 | 34.222222 | 163 | py |
ARSaliency | ARSaliency-main/models/VQSal/sal_model/modules/sal_losses.py | ## --------------------------------------------------------------------------
## Saliency in Augmented Reality
## Huiyu Duan, Wei Shen, Xiongkuo Min, Danyang Tu, Jing Li, and Guangtao Zhai
## ACM International Conference on Multimedia (ACM MM 2022)
## --------------------------------------------------------------------... | 21,884 | 43.034205 | 155 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.