repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
mmyolo
mmyolo-main/mmyolo/datasets/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .transforms import * # noqa: F401,F403 from .utils import BatchShapePolicy, yolov5_collate from .yolov5_coco import YOLOv5CocoDataset from .yolov5_crowdhuman import YOLOv5CrowdHumanDataset from .yolov5_dota import YOLOv5DOTADataset from .yolov5_voc import YOLOv5VOCD...
476
35.692308
68
py
mmyolo
mmyolo-main/mmyolo/datasets/yolov5_voc.py
# Copyright (c) OpenMMLab. All rights reserved. from mmdet.datasets import VOCDataset from mmyolo.datasets.yolov5_coco import BatchShapePolicyDataset from ..registry import DATASETS @DATASETS.register_module() class YOLOv5VOCDataset(BatchShapePolicyDataset, VOCDataset): """Dataset for YOLOv5 VOC Dataset. We...
465
28.125
73
py
mmyolo
mmyolo-main/mmyolo/datasets/yolov5_dota.py
# Copyright (c) OpenMMLab. All rights reserved. from mmyolo.datasets.yolov5_coco import BatchShapePolicyDataset from ..registry import DATASETS try: from mmrotate.datasets import DOTADataset MMROTATE_AVAILABLE = True except ImportError: from mmengine.dataset import BaseDataset DOTADataset = BaseDatase...
922
29.766667
74
py
mmyolo
mmyolo-main/mmyolo/datasets/transforms/mix_img_transforms.py
# Copyright (c) OpenMMLab. All rights reserved. import collections import copy from abc import ABCMeta, abstractmethod from typing import Optional, Sequence, Tuple, Union import mmcv import numpy as np from mmcv.transforms import BaseTransform from mmdet.structures.bbox import autocast_box_type from mmengine.dataset i...
46,505
39.404865
79
py
mmyolo
mmyolo-main/mmyolo/datasets/transforms/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .mix_img_transforms import Mosaic, Mosaic9, YOLOv5MixUp, YOLOXMixUp from .transforms import (LetterResize, LoadAnnotations, PPYOLOERandomCrop, PPYOLOERandomDistort, RegularizeRotatedBox, RemoveDataElement, YOLOv5CopyP...
732
47.866667
77
py
mmyolo
mmyolo-main/mmyolo/datasets/transforms/transforms.py
# Copyright (c) OpenMMLab. All rights reserved. import math from copy import deepcopy from typing import List, Sequence, Tuple, Union import cv2 import mmcv import numpy as np import torch from mmcv.transforms import BaseTransform, Compose from mmcv.transforms.utils import cache_randomness from mmdet.datasets.transfor...
59,261
37.037227
79
py
mmyolo
mmyolo-main/mmyolo/deploy/object_detection.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Callable, Dict, Optional import torch from mmdeploy.codebase.base import CODEBASE, MMCodebase from mmdeploy.codebase.mmdet.deploy import ObjectDetection from mmdeploy.utils import Codebase, Task from mmengine import Config from mmengine.registry import...
4,523
33.015038
78
py
mmyolo
mmyolo-main/mmyolo/deploy/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from mmdeploy.codebase.base import MMCodebase from .models import * # noqa: F401,F403 from .object_detection import MMYOLO, YOLOObjectDetection __all__ = ['MMCodebase', 'MMYOLO', 'YOLOObjectDetection']
253
30.75
57
py
mmyolo
mmyolo-main/mmyolo/deploy/models/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from . import dense_heads # noqa: F401,F403
93
30.333333
47
py
mmyolo
mmyolo-main/mmyolo/deploy/models/layers/bbox_nms.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from mmdeploy.core import mark from torch import Tensor def _efficient_nms( boxes: Tensor, scores: Tensor, max_output_boxes_per_class: int = 1000, iou_threshold: float = 0.5, score_threshold: float = 0.05, pre_top_k: int = -1, ke...
3,931
33.491228
78
py
mmyolo
mmyolo-main/mmyolo/deploy/models/layers/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .bbox_nms import efficient_nms __all__ = ['efficient_nms']
113
21.8
47
py
mmyolo
mmyolo-main/mmyolo/deploy/models/dense_heads/yolov5_head.py
# Copyright (c) OpenMMLab. All rights reserved. import copy from functools import partial from typing import List, Optional, Tuple import torch from mmdeploy.codebase.mmdet import get_post_processing_params from mmdeploy.codebase.mmdet.models.layers import multiclass_nms from mmdeploy.core import FUNCTION_REWRITER fro...
7,242
37.121053
79
py
mmyolo
mmyolo-main/mmyolo/deploy/models/dense_heads/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from . import yolov5_head # noqa: F401,F403 __all__ = ['yolov5_head']
120
23.2
47
py
mmyolo
mmyolo-main/mmyolo/engine/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .hooks import * # noqa: F401,F403 from .optimizers import * # noqa: F401,F403
133
32.5
47
py
mmyolo
mmyolo-main/mmyolo/engine/hooks/yolov5_param_scheduler_hook.py
# Copyright (c) OpenMMLab. All rights reserved. import math from typing import Optional import numpy as np from mmengine.hooks import ParamSchedulerHook from mmengine.runner import Runner from mmyolo.registry import HOOKS def linear_fn(lr_factor: float, max_epochs: int): """Generate linear function.""" retu...
4,611
34.206107
79
py
mmyolo
mmyolo-main/mmyolo/engine/hooks/ppyoloe_param_scheduler_hook.py
# Copyright (c) OpenMMLab. All rights reserved. import math from typing import Optional from mmengine.hooks import ParamSchedulerHook from mmengine.runner import Runner from mmyolo.registry import HOOKS @HOOKS.register_module() class PPYOLOEParamSchedulerHook(ParamSchedulerHook): """A hook to update learning ra...
3,781
37.989691
79
py
mmyolo
mmyolo-main/mmyolo/engine/hooks/yolox_mode_switch_hook.py
# Copyright (c) OpenMMLab. All rights reserved. import copy from typing import Sequence from mmengine.hooks import Hook from mmengine.model import is_model_wrapper from mmengine.runner import Runner from mmyolo.registry import HOOKS @HOOKS.register_module() class YOLOXModeSwitchHook(Hook): """Switch the mode of...
2,095
37.109091
79
py
mmyolo
mmyolo-main/mmyolo/engine/hooks/switch_to_deploy_hook.py
# Copyright (c) OpenMMLab. All rights reserved. from mmengine.hooks import Hook from mmengine.runner import Runner from mmyolo.registry import HOOKS from mmyolo.utils import switch_to_deploy @HOOKS.register_module() class SwitchToDeployHook(Hook): """Switch to deploy mode before testing. This hook converts...
630
27.681818
76
py
mmyolo
mmyolo-main/mmyolo/engine/hooks/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .ppyoloe_param_scheduler_hook import PPYOLOEParamSchedulerHook from .switch_to_deploy_hook import SwitchToDeployHook from .yolov5_param_scheduler_hook import YOLOv5ParamSchedulerHook from .yolox_mode_switch_hook import YOLOXModeSwitchHook __all__ = [ 'YOLOv5Para...
416
36.909091
76
py
mmyolo
mmyolo-main/mmyolo/engine/optimizers/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .yolov5_optim_constructor import YOLOv5OptimizerConstructor from .yolov7_optim_wrapper_constructor import YOLOv7OptimWrapperConstructor __all__ = ['YOLOv5OptimizerConstructor', 'YOLOv7OptimWrapperConstructor']
264
43.166667
75
py
mmyolo
mmyolo-main/mmyolo/engine/optimizers/yolov5_optim_constructor.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Optional import torch.nn as nn from mmengine.dist import get_world_size from mmengine.logging import print_log from mmengine.model import is_model_wrapper from mmengine.optim import OptimWrapper from mmyolo.registry import (OPTIM_WRAPPER_CONSTRUCTORS,...
5,201
38.112782
78
py
mmyolo
mmyolo-main/mmyolo/engine/optimizers/yolov7_optim_wrapper_constructor.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Optional import torch.nn as nn from mmengine.dist import get_world_size from mmengine.logging import print_log from mmengine.model import is_model_wrapper from mmengine.optim import OptimWrapper from mmyolo.models.dense_heads.yolov7_head import Implic...
5,576
38.835714
78
py
mmyolo
mmyolo-main/mmyolo/utils/labelme_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import json import os.path from mmengine.structures import InstanceData class LabelmeFormat: """Predict results save into labelme file. Base on https://github.com/wkentaro/labelme/blob/main/labelme/label_file.py Args: classes (tuple): Model classe...
2,799
29.107527
79
py
mmyolo
mmyolo-main/mmyolo/utils/large_image.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Sequence, Tuple import torch from mmcv.ops import batched_nms from mmdet.structures import DetDataSample, SampleList from mmengine.structures import InstanceData def shift_rbboxes(bboxes: torch.Tensor, offset: Sequence[int]): """Shift rotated bbo...
3,871
36.230769
79
py
mmyolo
mmyolo-main/mmyolo/utils/misc.py
# Copyright (c) OpenMMLab. All rights reserved. import os import urllib import numpy as np import torch from mmengine.utils import scandir from prettytable import PrettyTable from mmyolo.models import RepVGGBlock IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tiff', '....
4,932
35.813433
175
py
mmyolo
mmyolo-main/mmyolo/utils/setup_env.py
# Copyright (c) OpenMMLab. All rights reserved. import datetime import warnings from mmengine import DefaultScope def register_all_modules(init_default_scope: bool = True): """Register all modules in mmdet into the registries. Args: init_default_scope (bool): Whether initialize the mmdet default sco...
1,863
43.380952
93
py
mmyolo
mmyolo-main/mmyolo/utils/collect_env.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import mmdet from mmengine.utils import get_git_hash from mmengine.utils.dl_utils import collect_env as collect_base_env import mmyolo def collect_env() -> dict: """Collect the information of the running environments.""" env_info = collect_base_env(...
606
26.590909
70
py
mmyolo
mmyolo-main/mmyolo/utils/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .collect_env import collect_env from .misc import is_metainfo_lower, switch_to_deploy from .setup_env import register_all_modules __all__ = [ 'register_all_modules', 'collect_env', 'switch_to_deploy', 'is_metainfo_lower' ]
285
27.6
62
py
mmyolo
mmyolo-main/mmyolo/utils/boxam_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import bisect import copy import warnings from pathlib import Path from typing import Callable, List, Optional, Tuple, Union import cv2 import numpy as np import torch import torch.nn as nn import torchvision from mmcv.transforms import Compose from mmdet.evaluation impo...
19,429
36.875244
79
py
DALLE-pytorch
DALLE-pytorch-main/train_dalle.py
import argparse from pathlib import Path import time from glob import glob import os import shutil import torch import wandb # Quit early if user doesn't have wandb installed. from torch.nn.utils import clip_grad_norm_ from torch.optim import Adam from torch.optim.lr_scheduler import ReduceLROnPlateau from torch.util...
23,672
33.967504
199
py
DALLE-pytorch
DALLE-pytorch-main/setup.py
from setuptools import setup, find_packages exec(open('dalle_pytorch/version.py').read()) setup( name = 'dalle-pytorch', packages = find_packages(), include_package_data = True, version = __version__, license='MIT', description = 'DALL-E - Pytorch', author = 'Phil Wang', author_email = 'lucidrains@gmai...
1,149
23.468085
65
py
DALLE-pytorch
DALLE-pytorch-main/generate.py
import argparse from pathlib import Path from tqdm import tqdm # torch import torch from einops import repeat # vision imports from PIL import Image from torchvision.utils import make_grid, save_image # dalle related classes and utils from dalle_pytorch import __version__ from dalle_pytorch import DiscreteVAE, O...
4,695
31.611111
286
py
DALLE-pytorch
DALLE-pytorch-main/train_vae.py
import math from math import sqrt import argparse from pathlib import Path # torch import torch from torch.optim import Adam from torch.optim.lr_scheduler import ExponentialLR # vision imports from torchvision import transforms as T from torch.utils.data import DataLoader from torchvision.datasets import ImageFolde...
9,727
29.117647
168
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/reversible.py
import torch import torch.nn as nn from operator import itemgetter from torch.autograd.function import Function from torch.utils.checkpoint import get_device_states, set_device_states # for routing arguments into the functions of the reversible layer def route_args(router, args, depth): routed_args = [(dict(), dic...
5,390
33.120253
165
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/dalle_pytorch.py
from math import log2, sqrt import torch from torch import nn, einsum import torch.nn.functional as F import numpy as np from axial_positional_embedding import AxialPositionalEmbedding from einops import rearrange from dalle_pytorch import distributed_utils from dalle_pytorch.vae import OpenAIDiscreteVAE, VQGanVAE fr...
23,608
34.13244
170
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/vae.py
import io import sys import os import requests import PIL import warnings import hashlib import urllib import yaml from pathlib import Path from tqdm import tqdm from math import sqrt, log from packaging import version from omegaconf import OmegaConf from taming.models.vqgan import VQModel, GumbelVQ import importlib ...
7,674
31.939914
149
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/distributed_utils.py
""" Utility functions for optional distributed execution. To use, 1. set the `BACKENDS` to the ones you want to make available, 2. in the script, wrap the argument parser with `wrap_arg_parser`, 3. in the script, set and use the backend by calling `set_backend_from_args`. You can check whether a backend is in use ...
2,839
28.278351
79
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/version.py
__version__ = '1.6.6'
22
10.5
21
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/transformer.py
from collections import deque from collections.abc import Iterable from functools import partial from itertools import islice, cycle import torch from torch import nn, einsum import torch.nn.functional as F from einops import rearrange from dalle_pytorch.reversible import ReversibleSequence, SequentialSequence from d...
13,131
36.413105
180
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/tokenizer.py
# take from https://github.com/openai/CLIP/blob/main/clip/simple_tokenizer.py # to give users a quick easy start to training DALL-E without doing BPE import torch import youtokentome as yttm from tokenizers import Tokenizer from tokenizers.processors import ByteLevel from transformers import BertTokenizer import htm...
9,432
34.329588
120
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/__init__.py
from dalle_pytorch.dalle_pytorch import DALLE, CLIP, DiscreteVAE from dalle_pytorch.vae import OpenAIDiscreteVAE, VQGanVAE from pkg_resources import get_distribution from dalle_pytorch.version import __version__
213
34.666667
64
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/attention.py
from inspect import isfunction from math import ceil import torch from torch import nn, einsum import torch.nn.functional as F from einops import rearrange, repeat from rotary_embedding_torch import apply_rotary_emb # helpers def exists(val): return val is not None def uniq(arr): return{el: True for el in ...
14,131
34.418546
165
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/loader.py
from pathlib import Path from random import randint, choice import PIL from torch.utils.data import Dataset from torchvision import transforms as T class TextImageDataset(Dataset): def __init__(self, folder, text_len=256, image_size=128, trunca...
3,558
33.221154
112
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/distributed_backends/dummy_backend.py
from .distributed_backend import DistributedBackend class DummyBackend(DistributedBackend): """Acts like a distributed backend. Used as a stand-in replacement to obtain a non-distributed program. """ # We define this so we can use `super().__init__` but want this to # throw an error upon import....
1,222
22.075472
79
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/distributed_backends/distributed_backend.py
""" An abstract backend for distributed deep learning. Provides several standard utility methods under a common API. Please check the documentation of the class `DistributedBackend` for details to implement a new backend. """ from importlib import import_module class DistributedBackend: """An abstract backend c...
5,671
30.687151
79
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/distributed_backends/deepspeed_backend.py
import json import os import torch from .distributed_backend import DistributedBackend class DeepSpeedBackend(DistributedBackend): """Distributed backend using the DeepSpeed engine.""" BACKEND_MODULE_NAME = 'deepspeed' BACKEND_NAME = 'DeepSpeed' def wrap_arg_parser(self, parser): if not se...
5,987
33.813953
78
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/distributed_backends/horovod_backend.py
import torch from .distributed_backend import DistributedBackend class HorovodBackend(DistributedBackend): """Distributed backend using Horovod.""" BACKEND_MODULE_NAME = 'horovod.torch' BACKEND_NAME = 'Horovod' def wrap_arg_parser(self, parser): return parser def check_batch_size(self,...
1,703
27.881356
71
py
DALLE-pytorch
DALLE-pytorch-main/dalle_pytorch/distributed_backends/__init__.py
from .deepspeed_backend import DeepSpeedBackend from .distributed_backend import DistributedBackend from .dummy_backend import DummyBackend from .horovod_backend import HorovodBackend
184
36
51
py
covid-vax-stance
covid-vax-stance-main/classifier/classifier_predict.py
# Libraries import torch from torchtext.data import Field, TabularDataset, Iterator import torch.nn as nn import torch.nn.functional as F from transformers import AutoTokenizer, BertForSequenceClassification import os import csv import time import argparse import warnings torch.manual_seed(42) warnings.filterwarning...
5,168
33.46
176
py
libgpuarray
libgpuarray-master/setup.py
import sys import os import versioneer import distutils.command.clean import shutil have_cython = False try: import Cython if Cython.__version__ < '0.25': raise Exception('cython is too old or not installed ' '(at least 0.25 required)') from Cython.Build import cythonize ...
5,763
34.801242
146
py
libgpuarray
libgpuarray-master/versioneer.py
# Version: 0.18 """The Versioneer - like a rocketeer, but for versions. The Versioneer ============== * like a rocketeer, but for versions! * https://github.com/warner/python-versioneer * Brian Warner * License: Public Domain * Compatible With: python2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, and pypy * [![Latest Version] ...
68,610
36.65697
79
py
libgpuarray
libgpuarray-master/src/head.py
# Used to generate the string tables to embed the cluda headers. # Usage: python head.py <file> # This will output <file>.c def wrt(f, n, b): f.write(b',') n += 1 if n > 10: f.write(b'\n') n = 0 else: f.write(b' ') f.write(b"0x%02x" % (b,)) return n def convert(src, ds...
953
23.461538
78
py
libgpuarray
libgpuarray-master/src/gen_types.py
import sys from mako import exceptions from mako.template import Template TYPEMAP = {} i = 0 def add_type(name, C, sz): global i TYPEMAP[i] = ("ga_"+name, sz), name, C i+=1 add_type("bool", "uint8_t", 1) add_type("byte", "int8_t", 1) add_type("ubyte", "uint8_t", 1) for name, sz in [("short", 2), ("int...
4,777
19.245763
108
py
libgpuarray
libgpuarray-master/pygpu/reduction.py
import math import re from mako.template import Template import numpy from . import gpuarray from .tools import ScalarArg, ArrayArg, check_args, prod, lru_cache from .dtypes import parse_c_arg_backend def parse_c_args(arguments): return tuple(parse_c_arg_backend(arg, ScalarArg, ArrayArg) for a...
10,284
31.140625
77
py
libgpuarray
libgpuarray-master/pygpu/_array.py
from __future__ import division import numpy as np from .elemwise import elemwise1, elemwise2, ielemwise2, compare, arg, GpuElemwise, as_argument from .reduction import reduce1 from .dtypes import dtype_to_ctype, get_np_obj, get_common_dtype from . import gpuarray class ndgpuarray(gpuarray.GpuArray): """ Ext...
10,320
33.986441
94
py
libgpuarray
libgpuarray-master/pygpu/_version.py
# This file helps to compute a version number in source trees obtained from # git-archive tarball (such as those provided by githubs download-from-tag # feature). Distribution tarballs (built by setup.py sdist) and build # directories (produced by setup.py build) will contain a much shorter file # that just contains t...
18,503
34.516315
79
py
libgpuarray
libgpuarray-master/pygpu/tools.py
import functools import six from six.moves import reduce from heapq import nsmallest from operator import itemgetter, mul import numpy from .dtypes import dtype_to_ctype, _fill_dtype_registry from .gpuarray import GpuArray _fill_dtype_registry() def as_argument(obj, name): if isinstance(obj, GpuArray): ...
6,395
27.681614
76
py
libgpuarray
libgpuarray-master/pygpu/elemwise.py
import numpy from .dtypes import dtype_to_ctype, get_common_dtype from . import gpuarray from ._elemwise import GpuElemwise, arg __all__ = ['GpuElemwise', 'arg', 'as_argument', 'elemwise1', 'elemwise2', 'ielemwise2', 'compare'] def _dtype(o): if hasattr(o, 'dtype'): return o.dtype return ...
3,200
30.07767
78
py
libgpuarray
libgpuarray-master/pygpu/__init__.py
def get_include(): import os.path p = os.path.dirname(__file__) assert os.path.exists(os.path.join(p, 'gpuarray_api.h')) return p from . import gpuarray, elemwise, reduction from .gpuarray import (init, set_default_context, get_default_context, array, zeros, empty, asarray, ascon...
792
30.72
71
py
libgpuarray
libgpuarray-master/pygpu/dtypes.py
"""Type mapping helpers.""" from __future__ import division import numpy as np from . import gpuarray __copyright__ = "Copyright (C) 2011 Andreas Kloeckner" __license__ = """ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Softwa...
5,921
28.172414
75
py
libgpuarray
libgpuarray-master/pygpu/operations.py
from six.moves import range from .gpuarray import _split, _concatenate, dtype_to_typecode from .dtypes import upcast from . import asarray def atleast_1d(*arys): res = [] for ary in arys: ary = asarray(ary) if len(ary.shape) == 0: result = ary.reshape((1,)) else: ...
4,070
27.468531
79
py
libgpuarray
libgpuarray-master/pygpu/basic.py
from string import Template from .gpuarray import GpuArray, GpuKernel, SIZE, dtype_to_ctype import numpy def _generate_kernel(ctx, cols, dtype, upper=True): tmpl = Template(""" #include "cluda.h" KERNEL void extract_tri(GLOBAL_MEM ${ctype} *a, ga_size a_off, ga_uint N) { a = (GLOBAL_MEM ${ctype} *)...
2,407
29.871795
79
py
libgpuarray
libgpuarray-master/pygpu/tests/test_collectives.py
from __future__ import print_function import os import sys import unittest from six.moves import range from six import PY3 import pickle import numpy as np from pygpu import gpuarray from pygpu.collectives import COMM_ID_BYTES, GpuCommCliqueId, GpuComm from pygpu.tests.support import (check_all, gen_gpuarray, conte...
12,098
38.410423
100
py
libgpuarray
libgpuarray-master/pygpu/tests/main.py
import os import nose.plugins.builtin from nose.config import Config from nose.plugins.manager import PluginManager from numpy.testing.nosetester import NoseTester from numpy.testing.noseclasses import KnownFailure, NumpyTestProgram class NoseTester(NoseTester): """ Nose test runner. This class enables ...
4,535
34.162791
79
py
libgpuarray
libgpuarray-master/pygpu/tests/test_basic.py
import pygpu from pygpu.basic import (tril, triu) from unittest import TestCase from .support import (guard_devsup, gen_gpuarray, context) import numpy def test_tril(): for dtype in ['float32','float64']: for shape in [(10, 5), (5, 10), (10, 10)]: for order in ['c', 'f']: for ...
2,609
29.705882
68
py
libgpuarray
libgpuarray-master/pygpu/tests/test_reduction.py
import numpy from nose.tools import assert_raises from pygpu import gpuarray, ndgpuarray as elemary from pygpu.reduction import ReductionKernel from .support import (guard_devsup, check_meta_content, context, gen_gpuarray, dtypes_no_complex_big, dtypes_no_complex) def test_red_array_basic(): ...
4,645
30.181208
78
py
libgpuarray
libgpuarray-master/pygpu/tests/test_blas.py
from itertools import product import numpy from nose.plugins.skip import SkipTest from .support import (guard_devsup, gen_gpuarray, context) try: import scipy.linalg.blas try: fblas = scipy.linalg.blas.fblas except AttributeError: fblas = scipy.linalg.blas except ImportError as e: rai...
9,194
36.684426
83
py
libgpuarray
libgpuarray-master/pygpu/tests/support.py
from __future__ import print_function import os import sys import numpy from nose.plugins.skip import SkipTest from pygpu import gpuarray if numpy.__version__ < '1.6.0': skip_single_f = True else: skip_single_f = False dtypes_all = ["float32", "float64", "int8", "int16", "uint8", "uint16", ...
5,147
29.461538
76
py
libgpuarray
libgpuarray-master/pygpu/tests/test_tools.py
from pygpu.tools import check_args from .support import context, gen_gpuarray def test_check_args_simple(): ac, ag = gen_gpuarray((50,), 'float32', ctx=context) bc, bg = gen_gpuarray((50,), 'float32', ctx=context) n, nd, dims, strs, offsets = check_args((ag, bg)) assert n == 50 assert nd == 1 ...
3,878
31.596639
72
py
libgpuarray
libgpuarray-master/pygpu/tests/test_gpu_ndarray.py
from __future__ import print_function import unittest import copy from six.moves import range from six import PY3 import pickle import numpy from nose.tools import assert_raises import pygpu from pygpu.gpuarray import GpuArray, GpuKernel from .support import (guard_devsup, check_meta, check_flags, check_all, ...
26,790
31.162065
79
py
libgpuarray
libgpuarray-master/pygpu/tests/__init__.py
0
0
0
py
libgpuarray
libgpuarray-master/pygpu/tests/test_operations.py
import numpy import pygpu from .support import (gen_gpuarray, context, SkipTest) def test_array_split(): xc, xg = gen_gpuarray((8,), 'float32', ctx=context) rc = numpy.array_split(xc, 3) rg = pygpu.array_split(xg, 3) assert len(rc) == len(rg) for pc, pg in zip(rc, rg): numpy.testing.asse...
2,636
25.636364
77
py
libgpuarray
libgpuarray-master/pygpu/tests/test_elemwise.py
import operator import numpy from mako.template import Template from unittest import TestCase from pygpu import gpuarray, ndgpuarray as elemary from pygpu.dtypes import dtype_to_ctype, get_common_dtype from pygpu.elemwise import as_argument, ielemwise2 from pygpu._elemwise import GpuElemwise, arg from six import PY2 ...
11,580
32.37464
79
py
libgpuarray
libgpuarray-master/doc/conf.py
# -*- Coding: utf-8 -*- # # gpuarray documentation build configuration file, created by # sphinx-quickstart on Wed Nov 21 16:23:37 2012. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # Al...
9,714
30.852459
80
py
GENESIM
GENESIM-master/example.py
""" This is an example script that will apply k-cross-validation on all datasets with a load function in `data.load_datasets` and for all implemented tree constructors, ensemble techniques and GENESIM. In the end, a confusion matrices will be stored at path `output/dataset_name_CVk.png` and the average model complexity...
11,794
53.105505
153
py
GENESIM
GENESIM-master/decisiontree.py
""" Contains the decisiontree object used throughout this project. Written by Gilles Vandewiele in commission of IDLab - INTEC from University Ghent. """ from copy import deepcopy, copy import sklearn from graphviz import Source import matplotlib.pyplot as plt import numpy as np import json import operator from pand...
24,478
42.02109
152
py
GENESIM
GENESIM-master/RFTest.py
from sklearn.cross_validation import StratifiedKFold from sklearn.metrics import confusion_matrix from constructors.ensemble import RFClassification from data.load_all_datasets import load_all_datasets import numpy as np from decisiontree import DecisionTree from refined_rf import RefinedRandomForest rf = RFClassi...
3,492
35.385417
91
py
GENESIM
GENESIM-master/__init__.py
0
0
0
py
GENESIM
GENESIM-master/constructors/genesim.py
""" Contains the code for the innovative algorithm called GENESIM Written by Gilles Vandewiele in commission of IDLab - INTEC from University Ghent. """ import copy import multiprocessing from collections import Counter from pandas import DataFrame, concat import numpy as np import time import sys from sklearn.cr...
36,137
49.542657
182
py
GENESIM
GENESIM-master/constructors/inTrees.py
""" inTrees / STEL -------------- Merges different decision trees in an ensemble together in an ordered rule list Written by Gilles Vandewiele in commission of IDLab - INTEC from University Ghent. Reference: Houtao Deng "Interpreting Tree Ensembles with inTrees" """ import sys im...
10,783
33.899676
157
py
GENESIM
GENESIM-master/constructors/treeconstructor.py
""" Contains wrappers around well-known decision tree induction algorithms: C4.5, CART, QUEST and GUIDE. Written by Gilles Vandewiele in commission of IDLab - INTEC from University Ghent. """ import pandas as pd import numpy as np from sklearn.cross_validation import StratifiedKFold from sklearn.metrics import accura...
23,107
38.772806
151
py
GENESIM
GENESIM-master/constructors/__init__.py
""" Contains implementations for different classifiers: decision tree induction algorithms, ensemble techniques and GENESIM: GENetic Extraction of a Single, Interpretable Model Written by Gilles Vandewiele in commission of IDLab - INTEC from University Ghent. """
264
43.166667
111
py
GENESIM
GENESIM-master/constructors/ensemble.py
""" Contains wrappers around well-known ensemble techniques: Random Forest and XGBoost. Written by Gilles Vandewiele in commission of IDLab - INTEC from University Ghent. """ import time from bayes_opt import BayesianOptimization from sklearn.cross_validation import cross_val_score from sklearn.ensemble import AdaBoo...
12,560
38.5
121
py
GENESIM
GENESIM-master/constructors/ISM.py
""" Interpretable Single Model -------------------------- Merges different decision trees in an ensemble together in a single, interpretable decision tree Written by Gilles Vandewiele in commission of IDLab - INTEC from University Ghent. Reference: Van Assche, Anneleen, and Hendrik Blocke...
12,135
45.676923
141
py
GENESIM
GENESIM-master/data/load_datasets.py
"""Contains data set loading functions. If you want the test script to include a new dataset, a new function must be written in this module that returns a pandas Dataframe, the feature column names, the label column name and the dataset name. Written by Gilles Vandewiele in commission of IDLab - INTEC from University ...
16,311
47.692537
143
py
GENESIM
GENESIM-master/data/__init__.py
""" Contains the data files and two python files that are responsible for loading them in easily. In `data.load_datasets`, a load function for each dataset must be written. In `data.load_all_datasets` python introspection is used to easily load in all datasets with a load function. Written by Gilles Vandewiele in comm...
370
52
118
py
GENESIM
GENESIM-master/data/load_all_datasets.py
""" Uses python introspection to call all function in `data.load_datasets` Written by Gilles Vandewiele in commission of IDLab - INTEC from University Ghent. """ import data.load_datasets from inspect import getmembers, isfunction def load_all_datasets(): """ Uses python introspection to call all function i...
696
26.88
114
py
WiFi-CSI-Sensing-Benchmark
WiFi-CSI-Sensing-Benchmark-main/NTU_Fi_model.py
import torch import torchvision import torch.nn as nn import torch.nn.functional as F from einops import rearrange, reduce, repeat from einops.layers.torch import Rearrange, Reduce class NTU_Fi_MLP(nn.Module): def __init__(self, num_classes): super(NTU_Fi_MLP,self).__init__() self.fc = nn.Sequentia...
13,031
32.674419
128
py
WiFi-CSI-Sensing-Benchmark
WiFi-CSI-Sensing-Benchmark-main/dataset.py
import numpy as np import glob import scipy.io as sio import torch from torch.utils.data import Dataset, DataLoader def UT_HAR_dataset(root_dir): data_list = glob.glob(root_dir+'/UT_HAR/data/*.csv') label_list = glob.glob(root_dir+'/UT_HAR/label/*.csv') WiFi_data = {} for data_dir in data_list: ...
3,086
29.564356
105
py
WiFi-CSI-Sensing-Benchmark
WiFi-CSI-Sensing-Benchmark-main/UT_HAR_model.py
import torch import torchvision import torch.nn as nn import torch.nn.functional as F from einops import rearrange, reduce, repeat from einops.layers.torch import Rearrange, Reduce class UT_HAR_MLP(nn.Module): def __init__(self): super(UT_HAR_MLP,self).__init__() self.fc = nn.Sequential( ...
12,505
32.52815
128
py
WiFi-CSI-Sensing-Benchmark
WiFi-CSI-Sensing-Benchmark-main/run.py
import numpy as np import torch import torch.nn as nn import argparse from util import load_data_n_model def train(model, tensor_loader, num_epochs, learning_rate, criterion, device): model = model.to(device) optimizer = torch.optim.Adam(model.parameters(), lr = learning_rate) for epoch in range(num_epochs...
3,185
33.258065
140
py
WiFi-CSI-Sensing-Benchmark
WiFi-CSI-Sensing-Benchmark-main/self_supervised_model.py
import torch import torch.nn as nn from einops import rearrange, reduce, repeat from einops.layers.torch import Rearrange, Reduce import torch.nn.functional as F class MLP_Parrallel(nn.Module): def __init__(self): super(MLP_Parrallel, self).__init__() self.encoder_1 = MLP_encoder() self.en...
20,995
30.763994
128
py
WiFi-CSI-Sensing-Benchmark
WiFi-CSI-Sensing-Benchmark-main/util.py
from dataset import * from UT_HAR_model import * from NTU_Fi_model import * from widar_model import * from self_supervised_model import * import torch def load_data_n_model(dataset_name, model_name, root): classes = {'UT_HAR_data':7,'NTU-Fi-HumanID':14,'NTU-Fi_HAR':6,'Widar':22} if dataset_name == 'UT_HAR_data...
10,985
41.416988
140
py
WiFi-CSI-Sensing-Benchmark
WiFi-CSI-Sensing-Benchmark-main/widar_model.py
import torch import torchvision import torch.nn as nn import torch.nn.functional as F from einops import rearrange, reduce, repeat from einops.layers.torch import Rearrange, Reduce class Widar_MLP(nn.Module): def __init__(self, num_classes): super(Widar_MLP,self).__init__() self.fc = nn.Sequential(...
12,936
32.866492
128
py
WiFi-CSI-Sensing-Benchmark
WiFi-CSI-Sensing-Benchmark-main/self_supervised.py
import torch import torch.optim as optim import random import torch.nn as nn from util import load_unsupervised_data_n_model import argparse from torch.autograd import Variable class EntLoss(nn.Module): def __init__(self, args, lam1, lam2, pqueue=None): super(EntLoss, self).__init__() self.lam1 = ...
8,839
39.365297
139
py
deficient-efficient
deficient-efficient-master/darts_experiments.py
import json #settings = ['ACDC_%i'%n for n in [6, 12]] +\ # ['SepHashed_%.2f'%s for s in [0.09, 0.20, 0.38]] +\ settings = ['Generic_%.2f'%s for s in [0.03, 0.06, 0.12]] +\ ['Tucker_%.2f'%s for s in [0.24, 0.37, 0.54]] +\ ['TensorTrain_%.2f'%s for s in [0.27, 0.41, 0.59]] +\ ...
1,152
37.433333
96
py
deficient-efficient
deficient-efficient-master/main.py
''''Writing everything into one script..''' from __future__ import print_function import os import imp import sys import time import json import argparse import torch import torch.nn as nn import torch.optim as optim import torch.optim.lr_scheduler as lr_scheduler import torch.nn.functional as F import torchvision impo...
25,508
39.426307
141
py
deficient-efficient
deficient-efficient-master/count.py
'''Count parameters or mult-adds in models.''' from __future__ import print_function import math import torch import argparse from torch.autograd import Variable from models.wide_resnet import WideResNet, WRN_50_2 from models.darts import DARTS from models.MobileNetV2 import MobileNetV2 from funcs import what_conv_blo...
12,725
38.156923
138
py
deficient-efficient
deficient-efficient-master/funcs.py
import torch import torch.nn.functional as F from models import * from models.wide_resnet import parse_options def distillation(y, teacher_scores, labels, T, alpha): return F.kl_div(F.log_softmax(y/T, dim=1), F.softmax(teacher_scores/T, dim=1)) * (T*T * 2. * alpha)\ + F.cross_entropy(y, labels) * (1. - ...
2,477
26.533333
112
py
deficient-efficient
deficient-efficient-master/wrn_experiments.py
import json #settings = ['ACDC_%i'%n for n in [15, 48, 64]] +\ # ['SepHashed_%.2f'%s for s in [0.05, 0.2, 0.5]] +\ settings = ['Generic_%.2f'%s for s in [0.03, 0.1, 0.24]] +\ ['Tucker_%.2f'%s for s in [0.21, 0.41, 0.67]] +\ ['TensorTrain_%.2f'%s for s in [0.23, 0.44, 0.7]] +\ ...
1,201
39.066667
114
py