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 |
|---|---|---|---|---|---|---|
bnp | bnp-master/regression/models/attention.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
class MultiHeadAttn(nn.Module):
def __init__(self, dim_q, dim_k, dim_v, dim_out, num_heads=8):
super().__init__()
self.num_heads = num_heads
self.dim_out = dim_out
self.fc_q = nn.Linear(dim_q, dim_out, bi... | 1,805 | 35.857143 | 76 | py |
bnp | bnp-master/regression/utils/misc.py | import os
from importlib.machinery import SourceFileLoader
import math
import torch
def gen_load_func(parser, func):
def load(args, cmdline):
sub_args, cmdline = parser.parse_known_args(cmdline)
for k, v in sub_args.__dict__.items():
args.__dict__[k] = v
return func(**sub_args._... | 726 | 29.291667 | 65 | py |
bnp | bnp-master/regression/utils/log.py | import torch
import time
import logging
from collections import OrderedDict
def get_logger(filename, mode='a'):
logging.basicConfig(level=logging.INFO, format='%(message)s')
logger = logging.getLogger()
logger.addHandler(logging.FileHandler(filename, mode=mode))
return logger
class RunningAverage(obje... | 1,679 | 27 | 65 | py |
bnp | bnp-master/regression/utils/sampling.py | import torch
def gather(items, idxs):
K = idxs.shape[0]
idxs = idxs.to(items[0].device)
gathered = []
for item in items:
gathered.append(torch.gather(
torch.stack([item]*K), -2,
torch.stack([idxs]*item.shape[-1], -1)).squeeze(0))
return gathered[0] if len(gathered) =... | 1,343 | 32.6 | 73 | py |
bnp | bnp-master/regression/data/gp.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import MultivariateNormal, StudentT
from attrdict import AttrDict
import math
__all__ = ['GPSampler', 'RBFKernel', 'PeriodicKernel', 'Matern52Kernel']
class GPSampler(object):
def __init__(self, kernel, t_noise=None):
... | 4,122 | 35.8125 | 89 | py |
bnp | bnp-master/regression/data/emnist.py | import argparse
import torch
import torchvision.datasets as tvds
from utils.paths import datasets_path
from utils.misc import gen_load_func
class EMNIST(tvds.EMNIST):
def __init__(self, train=True, class_range=[0, 47], device='cpu', download=True):
super().__init__(datasets_path, train=train, split='bala... | 807 | 30.076923 | 89 | py |
bnp | bnp-master/regression/data/image.py | import torch
from attrdict import AttrDict
from torch.utils.data import DataLoader
from torch.distributions import StudentT, Normal
def img_to_task(img, num_ctx=None,
max_num_points=None, target_all=False, t_noise=None, device=None):
B, C, H, W = img.shape
num_pixels = H*W
img = img.view(B, C, -1)... | 2,725 | 28 | 80 | py |
bnp | bnp-master/regression/data/lotka_volterra.py | import torch
import numpy as np
import numpy.random as npr
import numba as nb
from tqdm import tqdm
from attrdict import AttrDict
#import pandas as pd
import wget
import os.path as osp
from utils.paths import datasets_path
@nb.njit(nb.i4(nb.f8[:]))
def catrnd(prob):
cprob = prob.cumsum()
u = npr.rand()
fo... | 6,466 | 31.497487 | 89 | py |
bnp | bnp-master/regression/data/celeba.py | import torch
import os.path as osp
import argparse
from utils.paths import datasets_path
from utils.misc import gen_load_func
class CelebA(object):
def __init__(self, train=True):
self.data, self.targets = torch.load(
osp.join(datasets_path, 'celeba',
'train.pt' if trai... | 2,735 | 31.963855 | 89 | py |
landing | landing-main/setup.py | #! /usr/bin/env python
from setuptools import setup
setup(name='landing',
install_requires=['torch', 'geoopt', 'scipy'],
packages=['landing'],
version='0.0'
) | 185 | 17.6 | 52 | py |
landing | landing-main/examples/plot_procrustes.py | """
A simple example of the landing algorithm on Procrustes problem
===============================================================
Given n pairs of matrices in an array A and B, we want to solve
in parallel the procrustes problems min_X ||XA - B|| where X is
orthogonal. We compare Riemannian gradient descent with the
... | 2,324 | 26.678571 | 78 | py |
landing | landing-main/examples/plot_nn_distillation.py | """
The landing algorithm to train a toy neural network on a distilation task
=========================================================================
"""
from time import time
import matplotlib.pyplot as plt
import torch
from torch import nn, optim
import geoopt
from geoopt.optim import RiemannianSGD
from landing ... | 2,899 | 26.102804 | 73 | py |
landing | landing-main/tests/test_landing.py | import pytest
import torch
import geoopt
from landing import LandingSGD
torch.manual_seed(1)
@pytest.mark.parametrize("momentum", [0, 0.5])
@pytest.mark.parametrize("shape", [(3, 3), (4, 3, 3), (5, 4, 3, 3)])
@pytest.mark.parametrize("safe_step", [0.3, False])
def test_forward(shape, momentum, safe_step):
para... | 2,207 | 29.246575 | 77 | py |
landing | landing-main/landing/optimizer.py | import torch
import torch.optim.optimizer
import geoopt
from geoopt.tensor import ManifoldParameter, ManifoldTensor
from geoopt.optim.mixin import OptimMixin
__all__ = ["LandingSGD"]
def _check_orthogonal(param):
if not hasattr(param, "manifold"):
raise TypeError("Parameter should be a geoopt parameter"... | 8,343 | 34.65812 | 79 | py |
Montreal-Forced-Aligner | Montreal-Forced-Aligner-main/montreal_forced_aligner/diarization/multiprocessing.py | """Multiprocessing functionality for speaker diarization"""
from __future__ import annotations
import logging
import multiprocessing as mp
import os
import queue
import subprocess
import sys
import time
import typing
from pathlib import Path
import dataclassy
import hdbscan
import kneed
import librosa
import numpy as... | 31,665 | 35.650463 | 119 | py |
Montreal-Forced-Aligner | Montreal-Forced-Aligner-main/montreal_forced_aligner/diarization/speaker_diarizer.py | """
Speaker classification
======================
"""
from __future__ import annotations
import collections
import csv
import logging
import os
import pickle
import random
import shutil
import subprocess
import sys
import time
import typing
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, List, Op... | 66,292 | 42.357096 | 168 | py |
Montreal-Forced-Aligner | Montreal-Forced-Aligner-main/montreal_forced_aligner/vad/multiprocessing.py | """Multiprocessing functionality for VAD"""
from __future__ import annotations
import logging
import os
import re
import subprocess
import typing
from pathlib import Path
from typing import TYPE_CHECKING, List, Union
import librosa
import numpy as np
import pynini
import pywrapfst
import sqlalchemy
from Bio import pa... | 22,837 | 35.599359 | 145 | py |
Montreal-Forced-Aligner | Montreal-Forced-Aligner-main/docs/source/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Montreal Forced Aligner documentation build configuration file, created by
# sphinx-quickstart on Wed Jun 15 13:27:38 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are pres... | 19,302 | 31.996581 | 102 | py |
PyTorch-VAE | PyTorch-VAE-master/experiment.py | import os
import math
import torch
from torch import optim
from models import BaseVAE
from models.types_ import *
from utils import data_loader
import pytorch_lightning as pl
from torchvision import transforms
import torchvision.utils as vutils
from torchvision.datasets import CelebA
from torch.utils.data import DataLo... | 4,997 | 38.354331 | 117 | py |
PyTorch-VAE | PyTorch-VAE-master/utils.py | import pytorch_lightning as pl
## Utils to handle newer PyTorch Lightning changes from version 0.6
## ==================================================================================================== ##
def data_loader(fn):
"""
Decorator to handle the deprecation of data_loader from 0.7
:param fn: Us... | 622 | 26.086957 | 106 | py |
PyTorch-VAE | PyTorch-VAE-master/dataset.py | import os
import torch
from torch import Tensor
from pathlib import Path
from typing import List, Optional, Sequence, Union, Any, Callable
from torchvision.datasets.folder import default_loader
from pytorch_lightning import LightningDataModule
from torch.utils.data import DataLoader, Dataset
from torchvision import tra... | 6,315 | 33.895028 | 118 | py |
PyTorch-VAE | PyTorch-VAE-master/run.py | import os
import yaml
import argparse
import numpy as np
from pathlib import Path
from models import *
from experiment import VAEXperiment
import torch.backends.cudnn as cudnn
from pytorch_lightning import Trainer
from pytorch_lightning.loggers import TensorBoardLogger
from pytorch_lightning.utilities.seed import seed_... | 2,216 | 34.758065 | 97 | py |
PyTorch-VAE | PyTorch-VAE-master/models/vq_vae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class VectorQuantizer(nn.Module):
"""
Reference:
[1] https://github.com/deepmind/sonnet/blob/v2/sonnet/src/nets/vqvae.py
"""
def __init__(self,
num_embeddings: in... | 7,576 | 32.675556 | 96 | py |
PyTorch-VAE | PyTorch-VAE-master/models/base.py | from .types_ import *
from torch import nn
from abc import abstractmethod
class BaseVAE(nn.Module):
def __init__(self) -> None:
super(BaseVAE, self).__init__()
def encode(self, input: Tensor) -> List[Tensor]:
raise NotImplementedError
def decode(self, input: Tensor) -> Any:
r... | 733 | 21.9375 | 78 | py |
PyTorch-VAE | PyTorch-VAE-master/models/twostage_vae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class TwoStageVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
hidden_dims2: Lis... | 6,867 | 33.862944 | 104 | py |
PyTorch-VAE | PyTorch-VAE-master/models/gamma_vae.py | import torch
from models import BaseVAE
from torch import nn
from torch.distributions import Gamma
from torch.nn import functional as F
from .types_ import *
import torch.nn.init as init
class GammaVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
... | 8,650 | 33.883065 | 117 | py |
PyTorch-VAE | PyTorch-VAE-master/models/swae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from torch import distributions as dist
from .types_ import *
class SWAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
... | 7,340 | 34.463768 | 109 | py |
PyTorch-VAE | PyTorch-VAE-master/models/cat_vae.py | import torch
import numpy as np
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class CategoricalVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
categorical_dim: int = 40, # Num class... | 7,531 | 35.038278 | 128 | py |
PyTorch-VAE | PyTorch-VAE-master/models/dip_vae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class DIPVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
lambda_diag: float = 1... | 6,597 | 33.544503 | 103 | py |
PyTorch-VAE | PyTorch-VAE-master/models/wae_mmd.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class WAE_MMD(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
reg_weight: int = 100... | 7,427 | 31.155844 | 81 | py |
PyTorch-VAE | PyTorch-VAE-master/models/mssim_vae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
from math import exp
class MSSIMVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
... | 9,644 | 33.081272 | 109 | py |
PyTorch-VAE | PyTorch-VAE-master/models/betatc_vae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
import math
class BetaTCVAE(BaseVAE):
num_iter = 0 # Global static variable to keep track of iterations
def __init__(self,
in_channels: int,
latent_dim: in... | 8,558 | 34.962185 | 130 | py |
PyTorch-VAE | PyTorch-VAE-master/models/dfcvae.py | import torch
from models import BaseVAE
from torch import nn
from torchvision.models import vgg19_bn
from torch.nn import functional as F
from .types_ import *
class DFCVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,... | 7,315 | 32.714286 | 104 | py |
PyTorch-VAE | PyTorch-VAE-master/models/fvae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class FactorVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
gamma: float = 40.,... | 8,251 | 35.192982 | 108 | py |
PyTorch-VAE | PyTorch-VAE-master/models/iwae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class IWAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
num_samples: int = 5,
... | 6,694 | 34.42328 | 106 | py |
PyTorch-VAE | PyTorch-VAE-master/models/vampvae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class VampVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
num_components: int =... | 6,760 | 33.671795 | 96 | py |
PyTorch-VAE | PyTorch-VAE-master/models/vanilla_vae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class VanillaVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
**kwargs) -> None... | 5,757 | 32.283237 | 104 | py |
PyTorch-VAE | PyTorch-VAE-master/models/logcosh_vae.py | import torch
import torch.nn.functional as F
from models import BaseVAE
from torch import nn
from .types_ import *
class LogCoshVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
alpha: float = 100.,
... | 6,292 | 33.576923 | 104 | py |
PyTorch-VAE | PyTorch-VAE-master/models/hvae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class HVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent1_dim: int,
latent2_dim: int,
hidden_dims: List = None,
... | 9,396 | 35.142308 | 107 | py |
PyTorch-VAE | PyTorch-VAE-master/models/joint_vae.py | import torch
import numpy as np
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class JointVAE(BaseVAE):
num_iter = 1
def __init__(self,
in_channels: int,
latent_dim: int,
categorical_dim: int,
... | 9,837 | 35.708955 | 128 | py |
PyTorch-VAE | PyTorch-VAE-master/models/cvae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class ConditionalVAE(BaseVAE):
def __init__(self,
in_channels: int,
num_classes: int,
latent_dim: int,
hidden_dims: List = No... | 6,079 | 33.350282 | 104 | py |
PyTorch-VAE | PyTorch-VAE-master/models/info_vae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class InfoVAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
alpha: float = -0.5,
... | 8,538 | 32.355469 | 100 | py |
PyTorch-VAE | PyTorch-VAE-master/models/miwae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
from torch.distributions import Normal
class MIWAE(BaseVAE):
def __init__(self,
in_channels: int,
latent_dim: int,
hidden_dims: List = None,
... | 6,969 | 35.11399 | 114 | py |
PyTorch-VAE | PyTorch-VAE-master/models/beta_vae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
class BetaVAE(BaseVAE):
num_iter = 0 # Global static variable to keep track of iterations
def __init__(self,
in_channels: int,
latent_dim: int,
... | 6,242 | 33.877095 | 104 | py |
PyTorch-VAE | PyTorch-VAE-master/models/types_.py | from typing import List, Callable, Union, Any, TypeVar, Tuple
# from torch import tensor as Tensor
Tensor = TypeVar('torch.tensor')
| 133 | 25.8 | 61 | py |
PyTorch-VAE | PyTorch-VAE-master/models/lvae.py | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
from math import floor, pi, log
def conv_out_shape(img_size):
return floor((img_size + 2 - 3) / 2.) + 1
class EncoderBlock(nn.Module):
def __init__(self,
in_channels: int,
... | 9,666 | 34.671587 | 103 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_cat_vae.py | import torch
import unittest
from models import GumbelVAE
from torchsummary import summary
class TestVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = GumbelVAE(3, 10)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))... | 951 | 24.052632 | 74 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_joint_Vae.py | import torch
import unittest
from models import JointVAE
from torchsummary import summary
class TestVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = JointVAE(3, 10, 40, 0.0)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device=... | 958 | 24.236842 | 74 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_wae.py | import torch
import unittest
from models import WAE_MMD
from torchsummary import summary
class TestWAE(unittest.TestCase):
def setUp(self) -> None:
self.model = WAE_MMD(3, 10, reg_weight = 100)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))
# print(summ... | 787 | 24.419355 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/text_cvae.py | import torch
import unittest
from models import CVAE
class TestCVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = CVAE(3, 40, 10)
def test_forward(self):
x = torch.randn(16, 3, 64, 64)
c = torch.randn(16, 40)
y = self.model(x, c)... | 705 | 24.214286 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_swae.py | import torch
import unittest
from models import SWAE
from torchsummary import summary
class TestSWAE(unittest.TestCase):
def setUp(self) -> None:
self.model = SWAE(3, 10, reg_weight = 100)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))
# print(summary(s... | 782 | 24.258065 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/bvae.py | import torch
import unittest
from models import BetaVAE
from torchsummary import summary
class TestVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = BetaVAE(3, 10, loss_type='H').cuda()
def test_summary(self):
print(summary(self.model, (3, 64, 6... | 846 | 25.46875 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_iwae.py | import torch
import unittest
from models import IWAE
from torchsummary import summary
class TestIWAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = IWAE(3, 10)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))
... | 904 | 24.138889 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_lvae.py | import torch
import unittest
from models import LVAE
from torchsummary import summary
class TestLVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = LVAE(3, [4,8,16,32,128], hidden_dims=[32, 64,128, 256, 512])
def test_summary(self):
print(summary... | 977 | 24.736842 | 81 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_vae.py | import torch
import unittest
from models import VanillaVAE
from torchsummary import summary
class TestVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = VanillaVAE(3, 10)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'... | 823 | 24.75 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/text_vamp.py | import torch
import unittest
from models import VampVAE
from torchsummary import summary
class TestVVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = VampVAE(3, latent_dim=10).cuda()
def test_summary(self):
print(summary(self.model, (3, 64, 64),... | 844 | 25.40625 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_miwae.py | import torch
import unittest
from models import MIWAE
from torchsummary import summary
class TestMIWAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = MIWAE(3, 10)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))
... | 1,057 | 24.190476 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_dipvae.py | import torch
import unittest
from models import DIPVAE
from torchsummary import summary
class TestDIPVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = DIPVAE(3, 64)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))
... | 1,145 | 25.651163 | 81 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_gvae.py | import torch
import unittest
from models import GammaVAE
from torchsummary import summary
class TestGammaVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = GammaVAE(3, 10)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu... | 920 | 22.025 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_fvae.py | import torch
import unittest
from models import FactorVAE
from torchsummary import summary
class TestFAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = FactorVAE(3, 10)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))... | 1,368 | 27.520833 | 98 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_dfc.py | import torch
import unittest
from models import DFCVAE
from torchsummary import summary
class TestDFCVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = DFCVAE(3, 10)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))
... | 914 | 21.875 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_logcosh.py | import torch
import unittest
from models import LogCoshVAE
from torchsummary import summary
class TestVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = LogCoshVAE(3, 10, alpha=10)
def test_summary(self):
print(summary(self.model, (3, 64, 64), de... | 832 | 25.03125 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_betatcvae.py | import torch
import unittest
from models import BetaTCVAE
from torchsummary import summary
class TestBetaTCVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = BetaTCVAE(3, 64, anneal_steps= 100)
def test_summary(self):
print(summary(self.model, (3... | 1,173 | 26.302326 | 81 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_hvae.py | import torch
import unittest
from models import HVAE
from torchsummary import summary
class TestHVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = HVAE(3, latent1_dim=10, latent2_dim=20)
def test_summary(self):
print(summary(self.model, (3, 64, ... | 840 | 25.28125 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_mssimvae.py | import torch
import unittest
from models import MSSIMVAE
from torchsummary import summary
class TestMSSIMVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = MSSIMVAE(3, 10)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu... | 920 | 22.025 | 64 | py |
PyTorch-VAE | PyTorch-VAE-master/tests/test_vq_vae.py | import torch
import unittest
from models import VQVAE
from torchsummary import summary
class TestVQVAE(unittest.TestCase):
def setUp(self) -> None:
# self.model2 = VAE(3, 10)
self.model = VQVAE(3, 64, 512)
def test_summary(self):
print(summary(self.model, (3, 64, 64), device='cpu'))
... | 1,147 | 25.697674 | 81 | py |
SGDL | SGDL-main/code/main.py | import torch
import time
import training
import model
import pickle
import utils
import dataloader
import parse
from parse import args, log_file
from prettytable import PrettyTable
utils.set_seed(args.seed)
mem_manager = dataloader.MemLoader(args)
train_dataset = dataloader.Loader(args)
Recmodel = model.LightGCN(trai... | 4,100 | 35.292035 | 119 | py |
SGDL | SGDL-main/code/dataloader.py | import torch
import numpy as np
import pandas as pd
from torch.utils.data import Dataset
from scipy.sparse import csr_matrix
import scipy.sparse as sp
from time import time
import parse
class MemLoader(Dataset):
'''
Memorization management
Function: generate and update memorized data
'''
def __init... | 15,363 | 33.44843 | 117 | py |
SGDL | SGDL-main/code/training.py | import numpy as np
import torch
import utils
import dataloader
from utils import timer
import model
import multiprocessing
from sklearn.mixture import GaussianMixture as GMM
from parse import args, log_file
import parse
from scheduler import Scheduler
from copy import deepcopy
CORES = multiprocessing.cpu_count() // 2
... | 21,779 | 39.634328 | 119 | py |
SGDL | SGDL-main/code/utils.py | import numpy as np
from sklearn.metrics import roc_auc_score
from parse import args
import torch
def EarlyStop(results, loss=False):
if loss:
min_i = results.index(min(results))
curr_i = len(results)-1
is_stop = True if curr_i-min_i >= args.stop_step else False
if results[-1] <= res... | 7,742 | 28.441065 | 105 | py |
SGDL | SGDL-main/code/model.py | from parse import args
import torch
from torch import nn
from copy import deepcopy
from collections import OrderedDict
from torch.autograd import Variable
def to_var(x, requires_grad=True):
if torch.cuda.is_available():
x = x.cuda()
return Variable(x, requires_grad=requires_grad)
class MetaModule(nn.M... | 9,447 | 34.122677 | 105 | py |
SGDL | SGDL-main/code/scheduler.py | import torch
import torch.nn as nn
import numpy as np
from torch.distributions.categorical import Categorical
class Scheduler(nn.Module):
def __init__(self, N):
super(Scheduler, self).__init__()
self.grad_lstm = nn.LSTM(N, 10, 1, bidirectional=True)
self.loss_lstm = nn.LSTM(1, 10, 1, bidir... | 2,684 | 39.074627 | 88 | py |
SGDL | SGDL-main/code/parse.py | import argparse
import os
from os.path import join
import sys
import torch
import utils
import multiprocessing
parser = argparse.ArgumentParser()
parser.add_argument('--batch_size', type=int, default=128)
parser.add_argument('--lr', type=float, default=0.0005, help='learning rate')
parser.add_argument('--test_u_batch... | 3,840 | 46.419753 | 147 | py |
ElasticBERT | ElasticBERT-main/finetune-static/evaluations.py | import logging
import os
import sys
sys.path.append('../')
import numpy as np
import torch
from torch.utils.data import DataLoader, SequentialSampler
from torch.utils.data.distributed import DistributedSampler
from tqdm import tqdm
from transformers import glue_compute_metrics
from elue import elue_compute_metrics,... | 5,779 | 34.900621 | 118 | py |
ElasticBERT | ElasticBERT-main/finetune-static/inferences.py | import os
import csv
import sys
import logging
sys.path.append('../')
import numpy as np
import torch
from torch.utils.data import DataLoader, SequentialSampler
from tqdm import tqdm
from transformers import glue_processors
from elue import elue_compute_metrics, elue_processors
from load_data import (
load_an... | 5,492 | 35.865772 | 118 | py |
ElasticBERT | ElasticBERT-main/finetune-static/run_glue.py | import argparse
import glob
import json
import logging
import os
import random
import time
from arguments import get_args
import numpy as np
import torch
from torch.utils.data import DataLoader, RandomSampler
from torch.utils.data.distributed import DistributedSampler
from tqdm import tqdm, trange
import fitlog
impo... | 19,979 | 38.253438 | 123 | py |
ElasticBERT | ElasticBERT-main/finetune-static/load_data.py | import os
import sys
import logging
sys.path.append('../')
import torch
from torch.utils.data import TensorDataset
from transformers import glue_convert_examples_to_features
from transformers import glue_output_modes
from transformers import glue_processors
from elue import (
elue_output_modes,
elue_processo... | 6,271 | 41.378378 | 150 | py |
ElasticBERT | ElasticBERT-main/finetune-static/run_elue.py | import argparse
from genericpath import exists
import glob
import json
import logging
import os
import random
import time
import sys
sys.path.append('../')
from arguments import get_args
import numpy as np
import torch
from torch.utils.data import DataLoader, RandomSampler
from torch.utils.data.distributed import Dis... | 19,442 | 38.3583 | 123 | py |
ElasticBERT | ElasticBERT-main/finetune-static/models/modeling_elasticbert.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... | 29,676 | 40.506294 | 119 | py |
ElasticBERT | ElasticBERT-main/FLOPs/flops_counter.py | '''
Copyright (C) 2019 Sovrasov V. - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the MIT license.
* You should have received a copy of the MIT license with
* this file. If not visit https://opensource.org/licenses/MIT
'''
import sys
from functools import partial
import ... | 22,023 | 34.125997 | 94 | py |
ElasticBERT | ElasticBERT-main/finetune-dynamic/run_elue_entropy.py | import argparse
import csv
import glob
import json
import logging
import os
import random
import time
import sys
sys.path.append('../')
from arguments import get_args
import numpy as np
import torch
from torch.utils.data import DataLoader, RandomSampler
from torch.utils.data.distributed import DistributedSampler
from... | 20,558 | 39.954183 | 153 | py |
ElasticBERT | ElasticBERT-main/finetune-dynamic/evaluations.py | import logging
import os
import csv
import sys
sys.path.append('../')
import numpy as np
import torch
from torch.utils.data import DataLoader, SequentialSampler
from torch.utils.data.distributed import DistributedSampler
from tqdm import tqdm
from transformers import glue_compute_metrics
from elue import elue_comput... | 17,808 | 36.651163 | 118 | py |
ElasticBERT | ElasticBERT-main/finetune-dynamic/inferences.py | import os
import csv
import sys
import logging
sys.path.append('../')
import numpy as np
import torch
from torch.utils.data import DataLoader, SequentialSampler
from tqdm import tqdm
from transformers import glue_compute_metrics
from transformers import glue_processors
from elue import elue_compute_metrics, elue_pr... | 14,047 | 38.240223 | 132 | py |
ElasticBERT | ElasticBERT-main/finetune-dynamic/run_elue_patience.py | import argparse
import csv
import glob
import json
import logging
import os
import random
import time
import sys
sys.path.append('../')
from arguments import get_args
import numpy as np
import torch
from torch.utils.data import DataLoader, RandomSampler
from torch.utils.data.distributed import DistributedSampler
from... | 20,662 | 39.835968 | 147 | py |
ElasticBERT | ElasticBERT-main/finetune-dynamic/load_data.py | import os
import sys
import logging
sys.path.append('../')
import torch
from torch.utils.data import TensorDataset
from transformers import glue_convert_examples_to_features
from transformers import glue_output_modes
from transformers import glue_processors
from transformers.trainer_utils import is_main_process
from... | 6,173 | 39.618421 | 150 | py |
ElasticBERT | ElasticBERT-main/finetune-dynamic/models/modeling_elasticbert_entropy.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... | 34,058 | 39.838129 | 146 | py |
ElasticBERT | ElasticBERT-main/finetune-dynamic/models/modeling_elasticbert_patience.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... | 34,299 | 40.028708 | 138 | py |
N-JetNet | N-JetNet-main/demo.py | from __future__ import print_function
import argparse
import os
import shutil
import time
import random
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim as optim
from pytorch_classification.train_and_test import *
from pytorch_classification.dataset ... | 8,426 | 37.834101 | 107 | py |
N-JetNet | N-JetNet-main/models/nin.py | import torch.nn as nn
import math
import torch.nn.functional as F
__all__ = ['nin']
class NiN(nn.Module):
def __init__(self,
num_classes):
super(NiN, self).__init__()
self.classifier = nn.Sequential(
nn.Conv2d(3, 192, kernel_size=5, stride=1, padding=2, \
... | 2,535 | 31.512821 | 73 | py |
N-JetNet | N-JetNet-main/models/nin_shared_srf.py | import torch.nn as nn
import math
from srf.structured_conv_layer import *
__all__ = ['nin_shared_srf']
class NiN_shared_srf(nn.Module):
def __init__(self,
num_classes,
init_k,
init_order,
init_scale,
learn_sigma,
use_... | 3,704 | 31.787611 | 81 | py |
N-JetNet | N-JetNet-main/pytorch_classification/dataset.py | import torchvision.transforms as transforms
import torchvision.datasets as datasets
import torch.utils.data as data
import random
import numpy as np
class dataCIFAR:
def __init__(self, dataset, batch, train=True, val=True, workers=4):
if val==True: assert(train==True)
if dataset == 'cifar10':
... | 2,119 | 35.551724 | 89 | py |
N-JetNet | N-JetNet-main/pytorch_classification/train_and_test.py | from __future__ import print_function
import time
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim as optim
import torch.utils.data as data
import torchvision.transforms as transforms
import torchvision.datasets as datasets
from pytorch_classification... | 4,838 | 31.26 | 106 | py |
N-JetNet | N-JetNet-main/pytorch_classification/utils/eval.py | from __future__ import print_function, absolute_import
__all__ = ['accuracy']
"""
From https://github.com/pytorch/examples/blob/master/imagenet/main.py#L247-L262
"""
class AverageMeter(object):
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.su... | 967 | 24.473684 | 81 | py |
N-JetNet | N-JetNet-main/srf/structured_conv_layer.py | # Import general dependencies
import numpy as np
import math
import torch
from torch.autograd import Variable
import torch.nn as nn
from torchvision import transforms
from torch.autograd import Function
from torch.distributions import normal
from srf.gaussian_basis_filters import *
import torch.nn.functional as F
impo... | 7,051 | 40.97619 | 93 | py |
N-JetNet | N-JetNet-main/srf/gaussian_basis_filters.py | import torch
from scipy import ndimage
import math
import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
""" Create the Gaussian derivative basis.
Input:
- x: the input grid
- hermite: a temporary variable (initialized as the grid x)
... | 6,915 | 28.181435 | 97 | py |
N-JetNet | N-JetNet-main/srf/tests/test_basis.py | import torch
import scipy
import math
import numpy as np
import matplotlib.pyplot as plt
import argparse
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
import sys
sys.path.append("../")
from gaussian_basis_filters import *
def main():
# Training settings
... | 1,728 | 31.018519 | 75 | py |
N-JetNet | N-JetNet-main/srf/tests/test_alexnet.py | import torch
import scipy
import math
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
import torch.optim as optim
import sys
sys.path.append("../")
sys.path.append("../../")
from gaussian_basis_filters import *... | 9,885 | 34.689531 | 86 | py |
S2AFF | S2AFF-main/s2aff/model.py | import os
import torch
# have to do this to avoid weird bugs
os.environ["TOKENIZERS_PARALLELISM"] = "false"
torch.multiprocessing.set_sharing_strategy("file_system")
import gc
import numpy as np
import lightgbm as lgb
import kenlm
from s2aff.text import fix_text
from s2aff.features import make_lightgbm_features, pars... | 13,588 | 36.852368 | 113 | py |
S2AFF | S2AFF-main/s2aff/timo/interface.py | """
This file contains the classes required by Semantic Scholar's
TIMO tooling.
You must provide a wrapper around your model, as well
as a definition of the objects it expects, and those it returns.
"""
from typing import List
from os.path import join, basename
import torch
from pydantic import BaseModel, BaseSettin... | 5,308 | 36.652482 | 114 | py |
GTA-RL | GTA-RL-master/reinforce_baselines.py | import torch
import torch.nn.functional as F
from torch.utils.data import Dataset
from scipy.stats import ttest_rel
import copy
from train import rollout, get_inner_model
class Baseline(object):
def wrap_dataset(self, dataset):
return dataset
def unwrap_batch(self, batch):
return batch, None
... | 8,213 | 32.120968 | 116 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.