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 |
|---|---|---|---|---|---|---|
GPSKet | GPSKet-master/GPSKet/operator/hamiltonian/hubbard.py | import jax
import jax.numpy as jnp
import numpy as np
import netket as nk
import netket.jax as nkjax
from numba import jit
from typing import List, Tuple, Union, Optional
from netket.utils.types import DType
from GPSKet.hilbert.discrete_fermion import FermionicDiscreteHilbert
from GPSKet.operator.fermion import Fermion... | 7,394 | 40.544944 | 142 | py |
GPSKet | GPSKet-master/GPSKet/operator/hamiltonian/ab_initio.py | import numpy as np
import netket as nk
import jax.numpy as jnp
import jax
from numba import jit
import netket.jax as nkjax
from typing import Optional
from functools import partial
from netket.utils.types import DType
from GPSKet.operator.fermion import FermionicDiscreteOperator, apply_hopping
from GPSKet.models imp... | 32,804 | 55.658031 | 164 | py |
GPSKet | GPSKet-master/GPSKet/vqs/mc/mc_state/expect.py | from functools import partial
from typing import Callable, Optional
import jax
import jax.numpy as jnp
import netket as nk
from netket.utils.types import PyTree
from netket.stats import Stats
from netket import jax as nkjax
from netket.vqs.mc.mc_state.state import MCState
from netket.vqs.mc.mc_state.expect import get_... | 2,690 | 29.235955 | 110 | py |
GPSKet | GPSKet-master/GPSKet/vqs/mc/mc_state/state_unique_samples.py | import netket as nk
import netket.jax as nkjax
import jax.numpy as jnp
from typing import Tuple, Optional, Callable, Any
from collections import defaultdict
import numpy as np
from netket.utils.types import PyTree
from netket.utils.dispatch import TrueT
from netket.utils.mpi import (
node_number as _rank,
mp... | 7,185 | 41.023392 | 251 | py |
GPSKet | GPSKet-master/GPSKet/vqs/mc/mc_state/state_stratified_sampling.py | import numpy as np
from GPSKet.vqs.mc.mc_state.state_unique_samples import MCStateUniqueSamples
import jax
import jax.numpy as jnp
from netket.stats.mpi_stats import (
sum as _sum
)
import netket.jax as nkjax
from netket.utils.mpi import (
node_number as _rank,
mpi_max_jax as _mpi_max_jax,
n_nodes ... | 7,298 | 45.788462 | 164 | py |
GPSKet | GPSKet-master/GPSKet/driver/autoreg_state_fitting.py | import jax
import jax.numpy as jnp
import numpy as np
from functools import partial
from typing import Tuple, Optional
from netket.utils.types import Array, SeedT
from netket.operator import AbstractOperator
from netket.utils import mpi
from netket.driver.vmc_common import info
from .abstract_state_fitting import Abstr... | 3,039 | 35.190476 | 155 | py |
GPSKet | GPSKet-master/GPSKet/driver/minSR.py | import numpy as np
import jax
import jax.numpy as jnp
from functools import partial
import netket as nk
from netket import VMC
from netket.stats import Stats
from netket.utils import mpi
from netket.stats._autocorr import integrated_time
from netket.stats.mc_stats import _split_R_hat
from GPSKet.vqs import MCStateU... | 4,129 | 33.705882 | 122 | py |
GPSKet | GPSKet-master/GPSKet/driver/abstract_state_fitting.py | import jax
import numpy as np
import netket.jax as nkjax
from textwrap import dedent
from typing import Optional, Tuple
from netket.utils import mpi
from netket.utils.types import SeedT, Array
from netket.vqs import MCState
from netket.operator import AbstractOperator
from netket.driver import AbstractVariationalDriver... | 2,145 | 31.515152 | 99 | py |
GPSKet | GPSKet-master/GPSKet/models/jastrow.py | import jax
import jax.numpy as jnp
from flax import linen as nn
from flax.linen.dtypes import promote_dtype
from jax.nn.initializers import normal
from netket.utils.types import Array, DType, NNInitFunc, Callable
from ..hilbert import FermionicDiscreteHilbert
def up_down_occupancies(x):
"""
Returns spin-up an... | 1,676 | 33.22449 | 124 | py |
GPSKet | GPSKet-master/GPSKet/models/pixelcnn.py | import jax.numpy as jnp
import netket as nk
import flax.linen as nn
from math import sqrt
from typing import Optional
from jax.nn.initializers import lecun_normal, zeros
from netket.hilbert.homogeneous import HomogeneousHilbert
from netket.utils.types import Array, DType, NNInitFunc, Callable
from netket.models.autoreg... | 4,901 | 36.707692 | 112 | py |
GPSKet | GPSKet-master/GPSKet/models/pfaffian.py | import numpy as np
import jax.numpy as jnp
import jax
from netket.utils.types import Array, DType, Callable
from typing import Tuple
from netket.utils import HashableArray
from jax.nn.initializers import normal
from flax import linen as nn
def get_gauss_leg_elements_Sy(n_grid):
x, w = np.polynomial.legendre.legga... | 7,358 | 50.461538 | 150 | py |
GPSKet | GPSKet-master/GPSKet/models/plaquetteqGPS.py | import jax
import jax.numpy as jnp
import numpy as np
import flax.linen as nn
from netket.utils import HashableArray
from netket.utils.types import NNInitFunc, Array, DType, Callable
from typing import Tuple, Union, Optional
from netket.hilbert.homogeneous import HomogeneousHilbert
from GPSKet.nn.initializers import no... | 6,923 | 52.261538 | 154 | py |
GPSKet | GPSKet-master/GPSKet/models/autoreg_qGPS.py | import abc
from typing import Tuple, Union, Optional
import jax
import jax.numpy as jnp
from jax.scipy.special import logsumexp
from flax import linen as nn
from netket.hilbert.homogeneous import HomogeneousHilbert
from netket.utils.types import NNInitFunc, Array, DType, Callable
from jax.nn.initializers import zeros, ... | 11,842 | 39.282313 | 234 | py |
GPSKet | GPSKet-master/GPSKet/models/backflow_jastrow.py | import jax
import jax.numpy as jnp
import flax.linen as nn
from typing import Tuple
from netket.utils.types import Array, NNInitFunc, Callable
from netket.utils import HashableArray
from .backflow import Backflow
from .jastrow import Jastrow
from ..hilbert.discrete_fermion import FermionicDiscreteHilbert
class Backfl... | 2,622 | 43.457627 | 125 | py |
GPSKet | GPSKet-master/GPSKet/models/qGPS.py | import jax
import jax.numpy as jnp
import numpy as np
import flax.linen as nn
from netket.utils import HashableArray
from netket.utils.types import NNInitFunc, Array, DType, Callable
from typing import Tuple, Union, Optional
from netket.hilbert.homogeneous import HomogeneousHilbert
from GPSKet.nn.initializers import no... | 8,442 | 48.95858 | 153 | py |
GPSKet | GPSKet-master/GPSKet/models/backflow.py | import jax
import jax.numpy as jnp
import numpy as np
import flax.linen as nn
from jax.scipy.special import logsumexp
from netket.utils import HashableArray
from netket.utils.types import Array, Callable
from GPSKet.hilbert import FermionicDiscreteHilbert
from GPSKet.models import occupancies_to_electrons
class Backf... | 4,261 | 51.617284 | 127 | py |
GPSKet | GPSKet-master/GPSKet/models/slater.py | import jax
import numpy as np
import jax.numpy as jnp
from flax import linen as nn
from typing import Tuple, Union, Optional
from GPSKet.hilbert import FermionicDiscreteHilbert
from netket.utils.types import Array, Callable, DType, NNInitFunc
from netket.utils import HashableArray
from functools import partial
# Dimen... | 26,429 | 65.240602 | 192 | py |
GPSKet | GPSKet-master/GPSKet/models/autoreg_qGPS_full.py | import numpy as np
import jax
from jax.nn.initializers import zeros
import jax.numpy as jnp
from jax.scipy.special import logsumexp
from typing import Union, Optional, Tuple, List
from netket.utils import HashableArray
from netket.utils.types import DType, NNInitFunc, Callable, Array
from flax import linen as nn
from G... | 15,671 | 46.490909 | 190 | py |
GPSKet | GPSKet-master/GPSKet/models/slater_jastrow.py | import jax
import jax.numpy as jnp
from jax.nn.initializers import normal
from flax import linen as nn
from typing import Union, Tuple
from netket.models import Jastrow
from netket.utils.types import Array, DType, NNInitFunc, Callable
from .slater import Slater
from .jastrow import Jastrow
from ..hilbert.discrete_fermi... | 2,582 | 41.344262 | 93 | py |
GPSKet | GPSKet-master/GPSKet/models/asymm_qGPS.py | import jax.numpy as jnp
import numpy as np
from flax import linen as nn
from typing import Union, Tuple
from netket.utils import HashableArray
from netket.utils.types import Array, Callable, DType, NNInitFunc
from .slater import Slater
from ..hilbert.discrete_fermion import FermionicDiscreteHilbert
from ..nn.initialize... | 4,806 | 35.416667 | 93 | py |
GPSKet | GPSKet-master/GPSKet/models/autoreg_plaquetteqGPS.py | import jax
import jax.numpy as jnp
import numpy as np
from jax.scipy.special import logsumexp
from typing import Tuple, Union, Optional
from netket.utils import HashableArray
from netket.hilbert.homogeneous import HomogeneousHilbert
from netket.utils.types import NNInitFunc, Array, DType, Callable
from jax.nn.initializ... | 8,576 | 43.21134 | 251 | py |
GPSKet | GPSKet-master/GPSKet/supervised/imag_time_step.py | import netket as nk
import jax
import jax.numpy as jnp
import copy
from netket.vqs.mc.mc_state.expect_chunked import get_local_kernel
from netket.vqs.mc import get_local_kernel_arguments, get_local_kernel
from netket.utils import wrap_afun
from flax.core import freeze
from functools import partial
class ImagTimeSt... | 2,952 | 43.074627 | 110 | py |
GPSKet | GPSKet-master/GPSKet/hilbert/discrete_fermion.py | from typing import Optional, Tuple
from numba import jit
import numpy as np
import jax
import jax.numpy as jnp
import netket as nk
from netket.hilbert.custom_hilbert import HomogeneousHilbert
class FermionicDiscreteHilbert(HomogeneousHilbert):
def __init__(
self,
N: int = 1,
n_elec: O... | 1,881 | 26.676471 | 118 | py |
GPSKet | GPSKet-master/GPSKet/hilbert/random/discrete_fermion.py | import numpy as np
import netket as nk
from GPSKet.hilbert.discrete_fermion import FermionicDiscreteHilbert
import jax
import jax.numpy as jnp
@nk.hilbert.random.random_state.dispatch
def random_state(hilb: FermionicDiscreteHilbert, key, batches: int, *, dtype=jnp.uint8):
shape = (batches, hilb.size)
if hilb... | 948 | 38.541667 | 100 | py |
GPSKet | GPSKet-master/GPSKet/hilbert/random/discrete_asep.py | import netket as nk
from GPSKet.hilbert import ASEPDiscreteHilbert
import jax
import jax.numpy as jnp
@nk.hilbert.random.random_state.dispatch
def random_state(hilb: ASEPDiscreteHilbert, key, batches: int, *, dtype=jnp.uint8):
shape = (batches, hilb.size)
out = jax.random.choice(key, jnp.array(hilb.local_stat... | 359 | 31.727273 | 83 | py |
GPSKet | GPSKet-master/GPSKet/optimizer/solvers.py | import jax.numpy as jnp
from netket.jax import tree_ravel
def pinv(A, b, rcond=1e-12, x0=None):
del x0
A = A.to_dense()
b, unravel = tree_ravel(b)
A_inv = jnp.linalg.pinv(A, rcond=rcond, hermitian=True)
x = jnp.dot(A_inv, b)
return unravel(x), None | 274 | 24 | 59 | py |
GPSKet | GPSKet-master/GPSKet/optimizer/sr_rmsprop.py | import jax
import jax.numpy as jnp
from jax.tree_util import tree_map
from dataclasses import dataclass
from typing import Callable, Optional
from netket.utils.types import PyTree, Scalar
from netket.vqs import VariationalState
from netket.optimizer.preconditioner import AbstractLinearPreconditioner
from .qgt import QG... | 2,432 | 29.797468 | 130 | py |
GPSKet | GPSKet-master/GPSKet/optimizer/sr_dense.py | import jax
import jax.numpy as jnp
import netket.jax as nkjax
from dataclasses import dataclass
from typing import Callable, Optional, Any
from netket.utils.types import PyTree, Scalar, ScalarOrSchedule
from netket.vqs import VariationalState
from netket.optimizer.preconditioner import AbstractLinearPreconditioner
from... | 1,184 | 28.625 | 108 | py |
GPSKet | GPSKet-master/GPSKet/optimizer/qgt/qgt_jacobian_dense_rmsprop.py | import jax
import jax.numpy as jnp
import netket.jax as nkjax
from flax import struct
from typing import Optional, Union
from netket.utils import mpi
from netket.nn import split_array_mpi
from netket.utils.types import PyTree, Scalar
from netket.optimizer import LinearOperator
from netket.optimizer.linear_operator impo... | 6,141 | 32.380435 | 94 | py |
GPSKet | GPSKet-master/GPSKet/optimizer/qgt/qgt_onthefly_rmsprop.py | import jax
import jax.numpy as jnp
import netket.jax as nkjax
from flax import struct
from typing import Optional, Union, Callable
from functools import partial
from jax.tree_util import Partial, tree_map
from netket.utils import mpi
from netket.utils.types import PyTree
from netket.stats import subtract_mean
from netk... | 6,297 | 29.425121 | 92 | py |
GPSKet | GPSKet-master/GPSKet/optimizer/qgt/qgt_jacobian_dense_unique_samples.py | import netket as nk
from netket.optimizer.qgt.qgt_jacobian_common import (sanitize_diag_shift, to_shift_offset, rescale)
from netket.optimizer.qgt.qgt_jacobian_dense import QGTJacobianDenseT
import netket.jax as nkjax
from typing import Tuple, Optional, Callable, Any
from netket.utils.types import PyTree
from netke... | 1,839 | 35.078431 | 173 | py |
GPSKet | GPSKet-master/tutorials/asep_example.py | import jax
import jax.numpy as jnp
import netket as nk
from scipy.sparse.linalg import eigs
from netket.hilbert import Qubit
from GPSKet.operator.hamiltonian import AsymmetricSimpleExclusionProcess
from GPSKet.models import qGPS, ARqGPS
from GPSKet.sampler import ARDirectSampler
from GPSKet.nn import normal
# Set up ... | 1,456 | 28.14 | 114 | py |
GPSKet | GPSKet-master/tutorials/hubbard_example.py | import jax
import jax.numpy as jnp
import netket as nk
from GPSKet.hilbert.discrete_fermion import FermionicDiscreteHilbert
from GPSKet.sampler.fermionic_hopping import MetropolisHopping
from GPSKet.operator.hamiltonian import FermiHubbard
from GPSKet.models import ASymmqGPS
# Set up Hilbert space
L = 6
n_elec = (3, ... | 1,496 | 26.722222 | 126 | py |
GPSKet | GPSKet-master/tutorials/autoreg_state_fitting_example.py | import os
import optax
import jax
import jax.numpy as jnp
import numpy as np
import netket as nk
import GPSKet as qk
from functools import partial
from GPSKet.datasets.h2o import BasisType
def count_spins_fermionic(spins):
zeros = jnp.zeros(spins.shape[0])
up_spins = spins&1
down_spins = (spins&2)/2
r... | 2,742 | 30.895349 | 139 | py |
GPSKet | GPSKet-master/tutorials/j1j2_example.py | import jax.numpy as jnp
import netket as nk
from mpi4py import MPI
from GPSKet.operator.hamiltonian import get_J1_J2_Hamiltonian
from GPSKet.models import qGPS, ARqGPS, get_sym_transformation_spin
from GPSKet.sampler import ARDirectSampler
from GPSKet.sampler.metropolis_fast import MetropolisFastExchange
# MPI variabl... | 2,235 | 30.942857 | 89 | py |
GPSKet | GPSKet-master/tutorials/abinitio_example.py | import netket as nk
import GPSKet.models as qGPS
import numpy as np
from GPSKet.hilbert.discrete_fermion import FermionicDiscreteHilbert
from GPSKet.sampler.fermionic_hopping import MetropolisHopping, MetropolisFastHopping
from GPSKet.operator.hamiltonian.ab_initio import AbInitioHamiltonian, AbInitioHamiltonianOnThe... | 5,602 | 39.309353 | 121 | py |
GPSKet | GPSKet-master/scripts/GPS_for_ab_initio/H_chain_timing_analysis.py | import sys
import numpy as np
import jax
import jax.numpy as jnp
from pyscf import scf, gto, ao2mo, lo
import netket as nk
from GPSKet.hilbert.discrete_fermion import FermionicDiscreteHilbert
from GPSKet.sampler.fermionic_hopping import MetropolisHopping
from GPSKet.operator.hamiltonian.ab_initio import AbInitioHa... | 2,852 | 26.171429 | 93 | py |
GPSKet | GPSKet-master/scripts/GPS_for_ab_initio/H4x4x4.py | import sys
import pickle
from os.path import exists
import numpy as np
import jax.numpy as jnp
from numba import jit
from flax import linen as nn
from pyscf import scf, gto, ao2mo, lo
import netket as nk
from netket.utils.mpi import (
MPI_py_comm as _MPI_comm,
node_number as _rank,
mpi_sum as _mpi_s... | 8,913 | 31.180505 | 205 | py |
GPSKet | GPSKet-master/scripts/GPS_for_ab_initio/H50_1D.py | import sys
import pickle
from os.path import exists
import numpy as np
import jax.numpy as jnp
from pyscf import scf, gto, ao2mo, lo
import netket as nk
from netket.utils.mpi import (
MPI_py_comm as _MPI_comm,
node_number as _rank,
)
import GPSKet.models as qGPS
from GPSKet.hilbert.discrete_fermion impor... | 5,014 | 29.210843 | 205 | py |
GPSKet | GPSKet-master/scripts/GPS_for_ab_initio/H2O.py | from os.path import exists
import numpy as np
import jax
import jax.numpy as jnp
import netket as nk
from netket.utils.types import Array
import GPSKet
import GPSKet.models as qGPS
from GPSKet.hilbert.discrete_fermion import FermionicDiscreteHilbert
from GPSKet.sampler.fermionic_hopping import MetropolisHopping
fro... | 10,546 | 36.667857 | 205 | py |
GPSKet | GPSKet-master/scripts/ARGPS/argps/vmc.py | import os
import time
import jax
import numpy as np
import netket as nk
import GPSKet as qk
from absl import app
from absl import flags
from absl import logging
from netket.utils.mpi import (
node_number as MPI_rank
)
from ml_collections import config_flags, ConfigDict
from argps.configs.common import resolve
from ... | 5,497 | 31.532544 | 125 | py |
GPSKet | GPSKet-master/scripts/ARGPS/argps/models.py | import jax
import jax.numpy as jnp
import numpy as np
import netket as nk
import GPSKet as qk
from scipy.linalg import circulant
from functools import partial
from flax import linen as nn
from netket.hilbert import HomogeneousHilbert
from netket.graph import AbstractGraph
from netket.utils import HashableArray
from net... | 12,731 | 38.7875 | 181 | py |
GPSKet | GPSKet-master/tests/test_arqgps.py | import jax
import jax.numpy as jnp
import numpy as np
import netket as nk
from tqdm import tqdm
from jax.scipy.special import logsumexp
from GPSKet.models import ARqGPS
key_in, key_ma = jax.random.split(jax.random.PRNGKey(np.random.randint(0, 100)))
L = 20
M = 2
dtype = jnp.complex128
batch_size = 16
g = nk.graph.Ch... | 4,452 | 34.34127 | 100 | py |
GPSKet | GPSKet-master/tests/test_arplaquetteqgps.py | import jax
import jax.numpy as jnp
import numpy as np
import netket as nk
from tqdm import tqdm
from scipy.linalg import circulant
from jax.scipy.special import logsumexp
from netket.utils import HashableArray
from GPSKet.models import ARPlaquetteqGPS
key_in, key_ma = jax.random.split(jax.random.PRNGKey(2))
L = 20
M ... | 4,975 | 36.413534 | 138 | py |
GPSKet | GPSKet-master/tests/test_asymmqgps.py | import jax
import jax.numpy as jnp
import numpy as np
import netket as nk
from GPSKet.models import ASymmqGPS, ASymmqGPSProd, occupancies_to_electrons
from GPSKet.hilbert import FermionicDiscreteHilbert
from tqdm import tqdm
key_in, key_ma = jax.random.split(jax.random.PRNGKey(np.random.randint(0, 100)))
B = 16
L = 1... | 5,108 | 39.547619 | 103 | py |
GPSKet | GPSKet-master/tests/test_ardirectsampler.py | import jax
import jax.numpy as jnp
import numpy as np
import netket as nk
from mpi4py import MPI
from GPSKet.models import ARqGPS
from GPSKet.sampler import ARDirectSampler
# MPI variables
comm = MPI.COMM_WORLD.Create(MPI.COMM_WORLD.Get_group())
rank = comm.Get_rank()
n_nodes = comm.Get_size()
# Model variables
key ... | 3,091 | 30.232323 | 96 | py |
GPSKet | GPSKet-master/tests/test_arqgpsfull.py | import jax
import jax.numpy as jnp
import numpy as np
import netket as nk
from tqdm import tqdm
from jax.scipy.special import logsumexp
from GPSKet.models import ARqGPSFull
key_in, key_ma = jax.random.split(jax.random.PRNGKey(np.random.randint(0, 100)))
L = 20
M = 2
dtype = jnp.complex128
batch_size = 16
g = nk.graph... | 4,177 | 36.981818 | 199 | py |
GPSKet | GPSKet-master/tests/test_slater.py | import jax
import jax.numpy as jnp
import numpy as np
import netket as nk
from GPSKet.models import Slater, occupancies_to_electrons
from GPSKet.hilbert import FermionicDiscreteHilbert
from tqdm import tqdm
key_in, key_ma = jax.random.split(jax.random.PRNGKey(np.random.randint(0, 100)))
B = 16
L = 10
n_elec = [5, 5]
... | 1,955 | 35.222222 | 86 | py |
Tree-Supervised | Tree-Supervised-main/train_tree_w_parallel_autocast.py | import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
from models import *
import torch.nn.functional as F
from utils.autoaugment import CIFAR10Policy
from utils.cutout import Cutout
import torch.backends.cudnn as cudnn
import torch
from torch import nn
import os
imp... | 10,912 | 38.255396 | 134 | py |
Tree-Supervised | Tree-Supervised-main/train_tree_detach.py | import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
from models.resnet_liu import *
import torch.nn.functional as F
from utils.autoaugment import CIFAR10Policy
from utils.cutout import Cutout
import torch.backends.cudnn as cudnn
import wandb
cudnn.benchmark = True... | 8,775 | 37.323144 | 120 | py |
Tree-Supervised | Tree-Supervised-main/train_origin_autocast.py | '''Train CIFAR10 with PyTorch.'''
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
import time
import torchvision
import torchvision.transforms as transforms
from torch.cuda.amp import GradScaler
from torch.cuda.amp import autocast
impo... | 5,093 | 31.44586 | 110 | py |
Tree-Supervised | Tree-Supervised-main/train_origin.py | '''Train CIFAR10 with PyTorch.'''
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
import time
import torchvision
import torchvision.transforms as transforms
import os
import argparse
from models import *
from configs import *
parser ... | 4,920 | 31.375 | 110 | py |
Tree-Supervised | Tree-Supervised-main/train_tree.py | import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
from models import *
import torch.nn.functional as F
from utils.autoaugment import CIFAR10Policy
from utils.cutout import Cutout
import torch.backends.cudnn as cudnn
import wandb
import torch
from torch import nn
... | 9,770 | 36.872093 | 116 | py |
Tree-Supervised | Tree-Supervised-main/train_image.py | import argparse
import os
import random
import shutil
import time
import warnings
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.multiprocessing as mp
import torch.utils.data
import torch.utils.data.distr... | 16,684 | 37.802326 | 91 | py |
Tree-Supervised | Tree-Supervised-main/train.py | import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
from models.resnet_liu import *
import torch.nn.functional as F
from utils.autoaugment import CIFAR10Policy
from utils.cutout import Cutout
import torch.backends.cudnn as cudnn
cudnn.benchmark=True
GPU_double=2
... | 9,677 | 42.013333 | 117 | py |
Tree-Supervised | Tree-Supervised-main/train_tree_w_parallel.py | import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
from models import *
import torch.nn.functional as F
from utils.autoaugment import CIFAR10Policy
from utils.cutout import Cutout
import torch.backends.cudnn as cudnn
import torch
from torch import nn
import os
imp... | 10,690 | 38.305147 | 134 | py |
Tree-Supervised | Tree-Supervised-main/train_bi_mutual.py | import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
from models.resnet_liu import *
import torch.nn.functional as F
from utils.autoaugment import CIFAR10Policy
from utils.cutout import Cutout
import torch.backends.cudnn as cudnn
import wandb
cudnn.benchmark = True... | 9,038 | 36.978992 | 116 | py |
Tree-Supervised | Tree-Supervised-main/models/resnet_liu.py | '''ResNet in PyTorch.
For Pre-activation ResNet, see 'preact_resnet.py'.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition. arXiv:1512.03385
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
expansion... | 14,660 | 37.379581 | 159 | py |
Tree-Supervised | Tree-Supervised-main/models/resnet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=dilation, groups=groups, bias=False, dila... | 24,617 | 36.47032 | 116 | py |
Tree-Supervised | Tree-Supervised-main/models/mobilenetv2.py | '''MobileNetV2 in PyTorch.
See the paper "Inverted Residuals and Linear Bottlenecks:
Mobile Networks for Classification, Detection and Segmentation" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Block(nn.Module):
'''expand + depthwise + pointwise'''
def __init... | 7,588 | 37.522843 | 114 | py |
Tree-Supervised | Tree-Supervised-main/models/vgg.py | '''VGG11/13/16/19 in Pytorch.'''
import torch
import torch.nn as nn
cfg = {
'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG16': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512,... | 2,351 | 30.783784 | 117 | py |
Tree-Supervised | Tree-Supervised-main/models/mobilenetv3.py | '''MobileNetV3 in PyTorch.
See the paper "Inverted Residuals and Linear Bottlenecks:
Mobile Networks for Classification, Detection and Segmentation" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
class hswish(nn.Module):
def forward(self, x):
... | 15,223 | 44.04142 | 124 | py |
Tree-Supervised | Tree-Supervised-main/models/wide_resnet.py | import torch
import torch.nn as nn
import torch.nn.init as init
import torch.nn.functional as F
from torch.autograd import Variable
import sys
import numpy as np
def conv3x3(in_planes, out_planes, stride=1):
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=True)
def conv_init... | 4,976 | 35.065217 | 135 | py |
Tree-Supervised | Tree-Supervised-main/models/common.py | import torch.nn
###
#%% activation functions
###
class Swish(torch.nn.Module):
def forward(self, x):
return x * torch.nn.functional.sigmoid(x, inplace=True)
class HSwish(torch.nn.Module):
def forward(self, x):
return x * torch.nn.functional.relu6(x + 3.0, inplace=True) / 6.0
class HSigmoid(t... | 6,825 | 27.441667 | 92 | py |
Tree-Supervised | Tree-Supervised-main/utils/cutout.py | import torch
import numpy as np
class Cutout(object):
"""Randomly mask out one or more patches from an image.
Args:
n_holes (int): Number of patches to cut out of each image.
length (int): The length (in pixels) of each square patch.
"""
def __init__(self, n_holes, length):
se... | 1,172 | 25.659091 | 82 | py |
catsetmat | catsetmat-master/src/main.py | import argparse
import os
import torch
import sys
import multiprocessing
from concurrent.futures import as_completed, ProcessPoolExecutor
from src.our_utils import get_home_path, mkdir_p, get_data_path
from src.results_analyzer import plot_results_by_max
sys.path.append(get_home_path())
from lib.hypersagnn.main import ... | 4,233 | 44.042553 | 119 | py |
catsetmat | catsetmat-master/src/data_reader.py | import numpy as np
import os
import pandas as pd
import pickle
import random
import torch
def pad_zeros(points, cardinality, _type='torch'):
if _type == 'np':
if points.shape[2] < cardinality:
# pad to fixed size
padding = np.zeros((points.shape[0], points.shape[1], cardinality - p... | 5,370 | 49.669811 | 122 | py |
catsetmat | catsetmat-master/src/results_analyzer.py | import pickle
import os
import numpy as np
import torch
from matplotlib import pyplot as plt
import pandas as pd
from src.our_modules import device
def plot_results(splits, result_path, model_name):
dfs = []
for split_id in splits:
pkl_file = os.path.join(result_path, '{}_{}.pkl'.format(model_name, s... | 5,113 | 39.267717 | 118 | py |
catsetmat | catsetmat-master/src/our_modules.py | import numpy as np
import torch
import torch.nn as nn
# device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device = torch.device('cpu')
# A custom position wise MLP.
# dims is a list, it would create multiple layer with torch.tanh between them
# We don't do residual and layer-norm, because this is... | 27,636 | 46.486254 | 120 | py |
catsetmat | catsetmat-master/src/hypersagnn_modules.py | import numpy as np
import torch
import torch.nn as nn
from src.our_modules import device
# A custom position wise MLP.
# dims is a list, it would create multiple layer with torch.tanh between them
# We don't do residual and layer-norm, because this is only used as the
# final classifier
def get_non_pad_mask(seq):... | 16,055 | 39.341709 | 125 | py |
catsetmat | catsetmat-master/src/our_utils.py | import errno
import multiprocessing
import numpy as np
import os
import pickle
import time
import torch.nn as nn
import torch
import sys
from concurrent.futures import as_completed, ProcessPoolExecutor
from gensim.models import Word2Vec
from sklearn.preprocessing import StandardScaler
def get_home_path():
# retur... | 6,327 | 36.443787 | 118 | py |
catsetmat | catsetmat-master/src/experimenter.py | import os
import pickle
import torch
import sys
import torch.nn as nn
from sklearn.metrics import roc_auc_score, pairwise
from sklearn.utils import shuffle
from tqdm.autonotebook import tqdm
from src.link_predictor import predict_links, get_auc_scores
from src.hypersagnn_modules import Classifier as Classifier_hypersa... | 16,242 | 45.144886 | 118 | py |
catsetmat | catsetmat-master/lib/fspool/main.py | import os, sys
import argparse
from datetime import datetime
import torch
import torch.nn as nn
import torchvision.transforms as transforms
import torchvision.datasets as datasets
import torch.multiprocessing as mp
import numpy as np
import torch.nn.functional as F
import torch.optim as optim
import scipy.optimize
from... | 7,346 | 31.082969 | 117 | py |
catsetmat | catsetmat-master/lib/fspool/temp.py | '''
# home_path = '/content/drive/My Drive/projects/textual_analysis_email/'
home_path = '/home/jupyter/project/textual_analysis_email'
# sample_path = os.path.join(home_path, 'sample_data')
data_params = {'home_path': home_path,
'r_label_file': 'id_p_map.txt',
'u_label_file': 'id_a_map... | 16,357 | 35.759551 | 189 | py |
catsetmat | catsetmat-master/lib/fspool/autoencoder/fspool.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class FSPool(nn.Module):
"""
Featurewise sort pooling. From:
FSPool: Learning Set Representations with Featurewise Sort Pooling.
"""
def __init__(self, in_channels, n_pieces, relaxed=False):
"""
in_channels... | 6,790 | 36.313187 | 128 | py |
catsetmat | catsetmat-master/lib/fspool/autoencoder/model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
import torchvision
from .fspool import FSPool, cont_sort
class SAE(nn.Module):
def __init__(self, encoder, decoder, latent_dim, latent_dim_encoder=None, encoder_args={}, decoder_args={}, classify=False, input_channels... | 8,264 | 30.188679 | 146 | py |
catsetmat | catsetmat-master/lib/fspool/autoencoder/data.py | import os
import math
import random
import torch
import torch.utils.data
import torchvision
import torchvision.transforms as transforms
import torchvision.transforms.functional as T
def collate(batch):
points, labels, n_points = zip(*batch)
point_tensor = torch.zeros(len(points), points[0].size(0), max(n_po... | 3,909 | 28.847328 | 107 | py |
catsetmat | catsetmat-master/lib/hypersagnn/main.py | from torch.nn.utils.rnn import pad_sequence
from torchsummary import summary
from gensim.models import Word2Vec
import tensorflow as tf
from scipy.sparse import csr_matrix
from scipy.sparse import vstack as s_vstack
import os
import time
import argparse
import warnings
import torch
from .random_walk import random_walk... | 28,119 | 35.95138 | 122 | py |
catsetmat | catsetmat-master/lib/hypersagnn/utils.py | import numpy as np
import torch
from tqdm import tqdm, trange
from sklearn.metrics import average_precision_score, precision_score, recall_score, f1_score
from sklearn.metrics import roc_auc_score, accuracy_score, matthews_corrcoef
from concurrent.futures import as_completed, ProcessPoolExecutor
import errno
import os
... | 7,319 | 25.813187 | 92 | py |
catsetmat | catsetmat-master/lib/hypersagnn/random_walk.py | import os
import time
import numpy as np
import networkx as nx
import random
from tqdm import tqdm
from pathlib import Path
import torch
from concurrent.futures import as_completed, ProcessPoolExecutor
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device_ids = [0, 1]
class Graph():
def __... | 8,218 | 27.940141 | 135 | py |
catsetmat | catsetmat-master/lib/hypersagnn/Modules.py | import torch.nn as nn
import torch.nn.functional as F
import torch
import numpy as np
from tqdm import tqdm, trange
import copy
import math
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device_ids = [0, 1]
def get_non_pad_mask(seq):
assert seq.dim() == 2
return seq.ne(0).type(torch.fl... | 20,477 | 32.029032 | 146 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/dataloader.py | # -*- coding: utf-8 -*-
# @Time : 3/8/22
# @Modified by : Juncheng B Li
# @Original Author : Yuan Gong
# @File : dataloader.py
# modified from:
# Author: David Harwath
# with some functions borrowed from https://github.com/SeanNaren/deepspeech.pytorch
import csv
import json
import torchaudio
import numpy as n... | 9,531 | 40.991189 | 233 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/run.py | # -*- coding: utf-8 -*-
# @Time : 3/8/22
# @Modified by : Juncheng B Li
# @Original Author : Yuan Gong
# @File : run.py
import argparse
import os
import ast
import pickle
import sys
import time
import torch
from torch.utils.data import WeightedRandomSampler
basepath = os.path.dirname(os.path.dirname(sys.path[0... | 11,956 | 63.983696 | 263 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/traintest.py | # -*- coding: utf-8 -*-
# @Time : 3/8/22
# @Modified by : Juncheng B Li
# @Original Author : Yuan Gong
# @File : traintest.py
import sys
import os
import datetime
sys.path.append(os.path.dirname(os.path.dirname(sys.path[0])))
from utilities import *
import time
import torch
from torch import nn
import numpy as... | 15,426 | 41.498623 | 182 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/demo.py | # -*- coding: utf-8 -*-
# @Time : 3/8/22
# @Modified by : Juncheng B Li
# @Original Author : Yuan Gong
# @File : demo.py
import os
import torch
from models import ASTModel
# download pretrained model in this directory
os.environ['TORCH_HOME'] = '../pretrained_models'
# assume each input spectrogram has 100 tim... | 829 | 36.727273 | 110 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/get_norm_stats.py | # -*- coding: utf-8 -*-
# @Time : 3/8/22
# @Modified by : Juncheng B Li
# @Original Author : Yuan Gong
# @File : get_norm_stats.py
# this is a sample code of how to get normalization stats for input spectrogram
import torch
import numpy as np
from src import dataloader
# set skip_norm as True only when you ... | 1,131 | 39.428571 | 188 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/models/AudioFnet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy
import math
import numpy as np
import re
from scipy import linalg
class FNetInput(nn.Module):
def __init__(self, config):
super().__init__()
self.layer_norm = nn.LayerNorm(config['... | 7,877 | 33.704846 | 105 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/models/HigherModels.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
def init_layer(layer):
if layer.weight.ndimension() == 4:
(n_out, n_in, height, width) = layer.weight.size()
n = n_in * height * width
elif layer.weight.ndimension() == 2:
(n_out, n) = layer.weight.size()
... | 4,936 | 28.562874 | 138 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/models/Net_mModal_mgpu.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy
import math
import numpy as np
# from model import * # Poyao's model.py
class ConvBlock(nn.Module):
def __init__(self, n_input_feature_maps, n_output_feature_maps, kernel_size, batch_norm = False, p... | 52,075 | 48.501901 | 298 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/models/AudioFFnet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy
import math
import numpy as np
import re
from scipy import linalg
class FFNetInput(nn.Module):
def __init__(self, config):
super().__init__()
self.layer_norm = nn.LayerNorm(config[... | 5,076 | 31.33758 | 100 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/models/pslaModels.py | import torch.nn as nn
import torch
from .HigherModels import *
from efficientnet_pytorch import EfficientNet
import torchvision
class ResNetAttention(nn.Module):
def __init__(self, args):
super(ResNetAttention, self).__init__()
self.__dict__.update(args.__dict__) # Instill all args into self
... | 5,238 | 40.579365 | 134 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/models/linearModels.py | import torch.nn as nn
import torch
import torch.nn.functional as F
import torchvision
class LinearModel(nn.Module):
def __init__(self, n_layers=3, input_dim=64, hidden_dim=128, label_dim=527):
super(LinearModel, self).__init__()
self.n_layers = n_layers
self.hidden_dim = hidden_dim
... | 7,213 | 40.94186 | 136 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/models/ast_models.py | # -*- coding: utf-8 -*-
# @Time : 3/8/22
# @Modified by : Juncheng B Li
# @Original Author : Yuan Gong
# @File : ast_models.py
import torch
import torch.nn as nn
from torch.cuda.amp import autocast
import os
import wget
os.environ['TORCH_HOME'] = '../../pretrained_models'
import timm
from timm.models.layers im... | 12,236 | 57.831731 | 224 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/utilities/stats.py | import numpy as np
from scipy import stats
from sklearn import metrics
import torch
def d_prime(auc):
standard_normal = stats.norm()
d_prime = standard_normal.ppf(auc) * np.sqrt(2.0)
return d_prime
def calculate_stats(output, target):
"""Calculate statistics including mAP, AUC, etc.
Args:
o... | 1,819 | 29.847458 | 117 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/src/utilities/util.py | import math
import pickle
import numpy as np
import torch
import torch.nn as nn
import random
from collections import namedtuple
def calc_recalls(S):
"""
Computes recall at 1, 5, and 10 given a similarity matrix S.
By convention, rows of S are assumed to correspond to images and columns are captions.
"... | 10,901 | 34.511401 | 140 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/egs/audioset/inference.py | # -*- coding: utf-8 -*-
# @Time : 3/8/22
# @Modified by : Juncheng B Li
# @Original Author : jeffcheng
# @Reference: a inference script for single audio, heavily base on demo.py and traintest.py
import os
import sys
import csv
import argparse
import numpy as np
import torch
import torchaudio
torchaudio.set_audi... | 3,757 | 32.553571 | 110 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/egs/audioset/ensemble.py | # -*- coding: utf-8 -*-
# @Time : 3/8/22
# @Modified by : Juncheng B Li
# @Original Author : Yuan Gong
# @File : ensemble.py
# get the ensemble result
import os, sys, argparse
parentdir = str(os.path.abspath(os.path.join(__file__ ,"../../..")))+'/src'
sys.path.append(parentdir)
import dataloader
import model... | 5,912 | 51.327434 | 252 | py |
AudioTaggingDoneRight | AudioTaggingDoneRight-main/egs/speechcommands/prep_sc.py | # -*- coding: utf-8 -*-
# @Time : 6/23/21 3:19 PM
# @Author : Yuan Gong
# @Affiliation : Massachusetts Institute of Technology
# @Email : yuangong@mit.edu
# @File : prep_sc.py
import numpy as np
import json
import os
import wget
from torchaudio.datasets import SPEECHCOMMANDS
# prepare the data of the speech... | 5,419 | 43.065041 | 147 | py |
filter-pruning-geometric-median | filter-pruning-geometric-median-master/pruning_cifar10.py | from __future__ import division
import os, sys, shutil, time, random
import argparse
import torch
import torch.backends.cudnn as cudnn
import torchvision.datasets as dset
import torchvision.transforms as transforms
from utils import AverageMeter, RecorderMeter, time_string, convert_secs2time, timing
import models
impo... | 28,893 | 43.452308 | 122 | py |
filter-pruning-geometric-median | filter-pruning-geometric-median-master/pruning_imagenet.py | # https://github.com/pytorch/vision/blob/master/torchvision/models/__init__.py
import argparse
import os, sys
import shutil
import time
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torchvision.transforms as transforms... | 30,109 | 43.020468 | 119 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.