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
pyGAT
pyGAT-master/models.py
import torch import torch.nn as nn import torch.nn.functional as F from layers import GraphAttentionLayer, SpGraphAttentionLayer class GAT(nn.Module): def __init__(self, nfeat, nhid, nclass, dropout, alpha, nheads): """Dense version of GAT.""" super(GAT, self).__init__() self.dropout = dro...
2,251
40.703704
126
py
pyGAT
pyGAT-master/train.py
from __future__ import division from __future__ import print_function import os import glob import time import random import argparse import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.autograd import Variable from utils import load_data, accur...
5,077
31.76129
109
py
pyGAT
pyGAT-master/visualize_graph.py
from graphviz import Digraph import torch import models def make_dot(var, params): """ Produces Graphviz representation of PyTorch autograd graph Blue nodes are the Variables that require grad, orange are Tensors saved for backward in torch.autograd.Function Args: var: output Variabl...
2,096
32.285714
85
py
M3ViT
M3ViT-main/main.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import argparse import cv2 import os import numpy as np import sys import torch from utils.config import create_config from utils.common_config import get_train_dataset, get_transformations,\ ...
6,157
36.779141
165
py
M3ViT
M3ViT-main/train_fastmoe.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import argparse import cv2 import os import numpy as np import sys import torch from torch.nn.parallel import DistributedDataParallel from utils.config import create_config from utils.common_confi...
22,951
44.995992
165
py
M3ViT
M3ViT-main/train_vit.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import argparse import cv2 import os import numpy as np import sys import torch from torch.nn.parallel import DistributedDataParallel from utils.config import create_config from utils.common_confi...
11,637
37.664452
165
py
M3ViT
M3ViT-main/evaluation/eval_semseg.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import warnings import cv2 import os.path import glob import json import numpy as np import torch from PIL ...
7,002
33.497537
120
py
M3ViT
M3ViT-main/evaluation/eval_normals.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import warnings import cv2 import os.path import numpy as np import glob import math import torch import js...
5,486
35.098684
106
py
M3ViT
M3ViT-main/evaluation/eval_edge.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import os import glob import json import torch import numpy as np from utils.utils import mkdir_if_missing from losses.loss_functions import BalancedCrossEntropyLoss from utils.mypath import MyPat...
5,634
37.074324
181
py
M3ViT
M3ViT-main/evaluation/eval_human_parts.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import warnings import cv2 import glob import json import os.path import numpy as np import torch from PIL ...
5,293
32.295597
120
py
M3ViT
M3ViT-main/evaluation/evaluate_utils.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) from audioop import mul import os import cv2 import imageio import numpy as np import json import torch import scipy.io as sio from utils.utils import get_output, mkdir_if_missing import numpy as ...
17,462
44.007732
161
py
M3ViT
M3ViT-main/evaluation/eval_depth.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import warnings import cv2 import os.path import numpy as np import glob import torch import json import sc...
4,173
29.028777
99
py
M3ViT
M3ViT-main/evaluation/eval_sal.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import warnings import cv2 import os.path import numpy as np import glob import json import torch from PIL ...
5,771
34.62963
108
py
M3ViT
M3ViT-main/models/seg_hrnet.py
# ------------------------------------------------------------------------------ # Copyright (c) Microsoft # Licensed under the MIT License. # Written by Ke Sun (sunk@mail.ustc.edu.cn) # Minor changes made by Simon Vandenhende # ------------------------------------------------------------------------------ from __futu...
20,391
37.621212
207
py
M3ViT
M3ViT-main/models/aspp.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import torch import torch.nn as nn import torch.nn.functional as F class DeepLabHead(nn.Sequential): def __init__(self, in_channels, num_classes): super(DeepLabHead, self).__init__( ...
2,423
31.32
101
py
M3ViT
M3ViT-main/models/nddr_cnn.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) """ Implementation of NDDR-CNN https://arxiv.org/abs/1801.08297 """ import torch import torch.nn as nn import torch.nn.functional as F import time class NDDRLayer(nn.Module): def __in...
4,239
37.899083
213
py
M3ViT
M3ViT-main/models/vit_up_head.py
import torch.nn as nn import torch.nn.functional as F from functools import partial import math # from .layers import trunc_normal_ # from ..builder import HEADS # from .decode_head import BaseDecodeHead from mmcv.cnn import build_norm_layer from models.decoder_head import BaseDecodeHead def _no_grad_trunc_normal_...
9,541
41.221239
119
py
M3ViT
M3ViT-main/models/custom_moe_layer.py
r""" Adaption to act as the MLP layer using an MoE MLP layer in transformer. """ import torch import torch.nn as nn from fmoe.layers import FMoE, _fmoe_general_global_forward from fmoe.linear import FMoELinear from functools import partial import tree import torch import torch.nn as nn from fmoe.functions import prepa...
12,708
39.346032
175
py
M3ViT
M3ViT-main/models/model_utils.py
def cal_flops(w, h, k, c_in, c_out): """ calculate the actual flops of one example c_in and c_out are vector across the whole batch """ return w * h * k * k * c_in * c_out def load_pretrained_v2(model, path): ckpt = torch.load(path)['state_dict'] model_state = model.state_dict() new_ckpt ...
559
25.666667
52
py
M3ViT
M3ViT-main/models/resnet.py
# # Code referenced from Torchvision import torch import torch.nn as nn # from torchvision.models.utils import load_state_dict_from_url from torch.hub import load_state_dict_from_url from models.model_utils import cal_flops import math __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', '...
30,315
37.569975
113
py
M3ViT
M3ViT-main/models/Jtrl.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) """ Implementation of PAD-Net. https://arxiv.org/abs/1805.04409 """ from re import A import torch import torch.nn as nn import torch.nn.functional as F from models.resnet import Bottleneck...
11,978
43.366667
128
py
M3ViT
M3ViT-main/models/cross_stitch.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) """ Implementation of cross-stitch networks https://arxiv.org/abs/1604.03539 """ import torch import torch.nn as nn import torch.nn.functional as F import time class ChannelWiseMultiply(...
4,052
35.513514
136
py
M3ViT
M3ViT-main/models/vits_gate.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn as nn from functools import partial, reduce from operator import mul from timm.mod...
6,404
37.125
120
py
M3ViT
M3ViT-main/models/vision_transformer_moe.py
import torch import torch.nn as nn from functools import partial import math from itertools import repeat # from torch._six import container_abcs import collections.abc import warnings from collections import OrderedDict from utils.helpers import load_pretrained,load_pretrained_pos_emb from models.custom_moe_layer impo...
27,705
45.099834
171
py
M3ViT
M3ViT-main/models/vit.py
import torch import torch.nn as nn from functools import partial import math from itertools import repeat # from torch._six import container_abcs import collections.abc import warnings from utils.helpers import load_pretrained # from .layers import DropPath, to_2tuple, trunc_normal_ # from ..builder import BACKBONES ...
20,796
40.263889
164
py
M3ViT
M3ViT-main/models/papnet_new.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) """ Implementation of PAD-Net. https://arxiv.org/abs/1805.04409 """ from re import A import torch import torch.nn as nn import torch.nn.functional as F from models.resnet import Bottleneck...
14,599
46.402597
219
py
M3ViT
M3ViT-main/models/mobilenetv3.py
""" Creates a MobileNetV3 Model as defined in: Andrew Howard, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang, Yukun Zhu, Ruoming Pang, Vijay Vasudevan, Quoc V. Le, Hartwig Adam. (2019). Searching for MobileNetV3 arXiv preprint arXiv:1905.02244. """ import torch.nn as nn import math __a...
7,613
31.538462
169
py
M3ViT
M3ViT-main/models/layers.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import torch import torch.nn as nn class SEBlock(nn.Module): """ Squeeze-and-excitation block """ def __init__(self, channels, r=16): super(SEBlock, self).__init__() self...
1,297
34.081081
102
py
M3ViT
M3ViT-main/models/resnet_dilated.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import torch.nn as nn class ResnetDilated(nn.Module): """ ResNet backbone with dilated convolutions """ def __init__(self, orig_resnet, dilate_scale=8): super(ResnetDilated, self...
3,634
31.168142
92
py
M3ViT
M3ViT-main/models/models.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import time import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import build_norm_layer class TamModule(nn.Module): def __init__(self, p, tasks, input_channels, nor...
13,792
47.911348
202
py
M3ViT
M3ViT-main/models/padnet.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) """ Implementation of PAD-Net. https://arxiv.org/abs/1805.04409 """ import torch import torch.nn as nn import torch.nn.functional as F from models.resnet import Bottleneck from models.laye...
10,861
41.596078
163
py
M3ViT
M3ViT-main/models/decoder_head.py
from abc import ABCMeta, abstractmethod import torch import torch.nn as nn from mmcv.cnn import normal_init from mmcv.runner import auto_fp16, force_fp32 # from mmseg.core import build_pixel_sampler # from mmseg.ops import resize # from ..builder import build_loss # from ..losses import accuracy class BaseDecodeHea...
9,089
37.846154
78
py
M3ViT
M3ViT-main/models/mtan.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) """ Implementation of MTAN https://arxiv.org/abs/1803.10704 """ import torch import torch.nn as nn import torch.nn.functional as F from models.resnet import ResNet, conv1x1, Bottleneck...
7,140
46.926174
149
py
M3ViT
M3ViT-main/models/mti_net.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) """ MTI-Net implementation based on HRNet backbone https://arxiv.org/pdf/2001.06902.pdf """ import torch import torch.nn as nn import torch.nn.functional as F from models.resnet import B...
7,605
43.22093
162
py
M3ViT
M3ViT-main/models/papnet.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) """ Implementation of PAD-Net. https://arxiv.org/abs/1805.04409 """ from re import A import torch import torch.nn as nn import torch.nn.functional as F from models.resnet import Bottleneck...
13,171
45.875445
219
py
M3ViT
M3ViT-main/models/gate_funs/noisy_gate_vmoe.py
r""" Noisy gate for gshard and switch """ from fmoe.gates.base_gate import BaseGate import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions.normal import Normal import math import numpy as np from collections import Counter from pdb import set_trace class NoisyGate_VMoE(BaseGate): ...
13,246
41.594855
165
py
M3ViT
M3ViT-main/models/gate_funs/noisy_gate.py
r""" Noisy gate for gshard and switch """ from fmoe.gates.base_gate import BaseGate import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions.normal import Normal import math from pdb import set_trace class NoisyGate(BaseGate): def __init__(self, d_model, num_expert, world_size,...
8,344
35.441048
144
py
M3ViT
M3ViT-main/train/train_utils.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) from evaluation.evaluate_utils import PerformanceMeter from utils.utils import AverageMeter, ProgressMeter, get_output import numpy as np from collections import Counter import torch.nn.functional...
11,942
41.806452
117
py
M3ViT
M3ViT-main/utils/moe_utils.py
from collections import OrderedDict from models.gate_funs.noisy_gate import NoisyGate from models.gate_funs.noisy_gate_vmoe import NoisyGate_VMoE from models.custom_moe_layer import FMoETransformerMLP import torch.distributed import os from pdb import set_trace import torch.nn.functional as F import shutil def gathe...
8,324
35.195652
129
py
M3ViT
M3ViT-main/utils/common_config.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import os import copy import torch import torch.nn.functional as F import math import numpy as np from torchvision import transforms from torch.utils.data import DataLoader from utils.custom_colla...
40,973
47.894988
235
py
M3ViT
M3ViT-main/utils/sampler.py
from __future__ import division import math import numpy as np import torch import math import torch.distributed as dist from torch.utils.data.sampler import Sampler from .helpers import get_dist_info from torch.utils.data import DistributedSampler as _DistributedSampler # from torch.utils.data import Sampler clas...
7,997
34.705357
87
py
M3ViT
M3ViT-main/utils/custom_collate.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import torch import collections import re # from torch._six import string_classes, int_classes string_class...
2,785
32.97561
111
py
M3ViT
M3ViT-main/utils/utils.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import os import torch import torch.nn.functional as F import errno def mkdir_if_missing(directory): if not os.path.exists(directory): try: os.makedirs(directory) #...
2,115
25.78481
91
py
M3ViT
M3ViT-main/utils/helpers.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International from collections import OrderedDict import torch import cv2 import numpy as np import torch.nn.functional ...
13,546
40.176292
190
py
M3ViT
M3ViT-main/data/custom_transforms.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import numpy.random as random import numpy as np import torch import cv2 import math import utils.helpe...
10,478
31.84953
144
py
M3ViT
M3ViT-main/data/cityscapes.py
from torch.utils.data.dataset import Dataset import os import torch import torch.nn.functional as F import fnmatch import numpy as np import random from utils.mypath import MyPath import cv2 class RandomScaleCrop(object): """ Credit to Jialong Wu from https://github.com/lorenmt/mtan/issues/34. """ def ...
11,485
45.502024
154
py
M3ViT
M3ViT-main/data/pascal_context.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import os import sys import tarfile import json import cv2 import numpy as np import scipy.io as sio impor...
20,820
40.148221
118
py
M3ViT
M3ViT-main/data/nyud.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import os import sys import tarfile import cv2 from PIL import Image import numpy as np import torch.utils...
10,411
34.780069
106
py
M3ViT
M3ViT-main/losses/loss_functions.py
# This code is referenced from # https://github.com/facebookresearch/astmt/ # # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # License: Attribution-NonCommercial 4.0 International import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.modules.module import Modu...
6,352
31.085859
121
py
M3ViT
M3ViT-main/losses/loss_schemes.py
# # Authors: Simon Vandenhende # Licensed under the CC BY-NC 4.0 license (https://creativecommons.org/licenses/by-nc/4.0/) import torch import torch.nn as nn import torch.nn.functional as F class SingleTaskLoss(nn.Module): def __init__(self, loss_ft, task): super(SingleTaskLoss, self).__init__() ...
9,691
38.080645
114
py
mechamodlearn
mechamodlearn-master/setup.py
from setuptools import setup, find_packages def get_long_description(): with open("README.md", "r") as readme_file: return readme_file.read() setup( name='mechamodlearn', description='PyTorch framework for learning mechanical systems', long_description=get_long_description(), long_descri...
968
25.189189
68
py
mechamodlearn
mechamodlearn-master/mechamodlearn/rigidbody.py
# File: rigidbody.py import abc import torch from mechamodlearn import nn, utils from mechamodlearn.models import CholeskyMMNet, PotentialNet, GeneralizedForceNet class AbstractRigidBody: @property @abc.abstractmethod def thetamask(self): """Returns theta mask for configuration q. These...
5,598
29.102151
100
py
mechamodlearn
mechamodlearn-master/mechamodlearn/viz_utils.py
# # File: viz_utils.py # import matplotlib.pyplot as plt import torch from mechamodlearn.odesolver import odeint from mechamodlearn import utils def plot_traj(system_x_T_B, model_x_T_B, tstar): D = system_x_T_B.shape[-1] cm = plt.get_cmap('tab10') fig, axs = plt.subplots(1, D, figsize=(6 * D, 6), squeeze...
1,915
33.836364
99
py
mechamodlearn
mechamodlearn-master/mechamodlearn/transform.py
# File: transform.py # import functools from more_itertools import windowed import torch from mechamodlearn.dataset import ActuatedTrajectoryDataset, ODEPredDataset def fill_windowed(ls, traj_T_D, chunk_size, step): qs_ms = windowed(traj_T_D, chunk_size, step=step) for q in qs_ms: for i, cq in enum...
1,694
32.235294
98
py
mechamodlearn
mechamodlearn-master/mechamodlearn/utils.py
# File: utils.py # import random import sys from contextlib import contextmanager try: import resource except ImportError: # resource not available on Windows resource = None import numpy as np from numba import jit import timeit import torch def bfill_lowertriangle(A: torch.Tensor, vec: torch.Tensor): ...
3,699
23.666667
106
py
mechamodlearn
mechamodlearn-master/mechamodlearn/dataset.py
# File: dataset.py # import torch from torch.utils.data import dataset from mechamodlearn.odesolver import odeint, ActuatedODEWrapper from mechamodlearn import utils class ActuatedTrajectoryDataset(dataset.TensorDataset): def __init__(self, traj_q_T_B, traj_v_T_B, traj_u_T_B): """ Arguments: ...
2,746
33.772152
97
py
mechamodlearn
mechamodlearn-master/mechamodlearn/nn.py
# File: nn.py # import torch class Identity(torch.nn.Module): def __init__(self): super().__init__() def forward(self, x): return x ACTIVATIONS = { 'tanh': torch.nn.Tanh, 'relu': torch.nn.ReLU, 'elu': torch.nn.ELU, 'identity': Identity } class LNMLP(torch.nn.Module): ...
1,728
24.80597
90
py
mechamodlearn
mechamodlearn-master/mechamodlearn/models.py
# File: models.py # import torch from mechamodlearn import nn, utils class SharedMMVEmbed(torch.nn.Module): def __init__(self, qdim, hidden_sizes): self._qdim = qdim self._hidden_sizes = hidden_sizes super().__init__() self._lnet = nn.LNMLP(qdim, hidden_sizes[:-1], hidden_sizes[-...
4,469
26.592593
95
py
mechamodlearn
mechamodlearn-master/mechamodlearn/odesolver.py
# # File: odesolver.py # import abc import torch class FixedGridODESolver(metaclass=abc.ABCMeta): def __init__(self, func, y0, grid_constructor=None, transforms=None): self.func = func self.y0 = y0 if grid_constructor is None: grid_constructor = lambda f, y0, t: t s...
5,822
27.684729
100
py
mechamodlearn
mechamodlearn-master/mechamodlearn/trainer.py
# # File: trainer.py # from typing import Dict, List, Optional, Tuple import abc import datetime from pathlib import Path import re import os import shutil import time import traceback import numpy as np import torch import torch.nn.functional as F import tqdm from mechamodlearn import dataset, logger, nested, trans...
21,179
38.887006
99
py
mechamodlearn
mechamodlearn-master/mechamodlearn/systems/mlacrobot.py
# # File: mlacrobot.py # import torch from mechamodlearn.rigidbody import AbstractRigidBody from mechamodlearn.models import ControlAffineLinearForce, ViscousJointDampingForce, GeneralizedForces class MultiLinkAcrobotMM(torch.nn.Module): def __init__(self, qdim, params=None): super().__init__() ...
4,875
31.078947
102
py
mechamodlearn
mechamodlearn-master/mechamodlearn/systems/pendulum.py
# File: pendulum.py # import torch from mechamodlearn.rigidbody import AbstractRigidBody from mechamodlearn.models import ControlAffineLinearForce, ViscousJointDampingForce, GeneralizedForces class SimplePendulumMM(torch.nn.Module): def __init__(self, l): """ Arguments: - `l`: length of...
2,694
23.724771
102
py
mechamodlearn
mechamodlearn-master/mechamodlearn/systems/__init__.py
import torch from .pendulum import ActuatedDampedPendulum, ActuatedSimplePendulum from .mlacrobot import MultiLinkAcrobot, DampedMultiLinkAcrobot DEFAULT_SYS_PARAMS = { 'simplependulum': torch.tensor([1.0, 1.0, 1.0]), 'dampedpendulum': torch.tensor([1.0, 10.0, 1.0, -0.5]), '2linkdampedacrobot': torch.tens...
379
33.545455
92
py
mechamodlearn
mechamodlearn-master/experiments/simple.py
#!/usr/bin/env python3 # # File: simple.py # from datetime import datetime from pathlib import Path import click import torch from mechamodlearn import dataset, utils, viz_utils from mechamodlearn.trainer import OfflineTrainer from mechamodlearn.systems import ActuatedDampedPendulum, DampedMultiLinkAcrobot, DEFAULT_S...
3,755
37.721649
100
py
linlearn
linlearn-master/docs/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
4,773
29.602564
115
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/atari/custom_occlusion_sensitvity.py
""" This module was adapted from a module in https://github.com/sicara/tf-explain Date: 2020 commit: 8dff129ff7b1012dba2761a61e3c3e68e9ecbec2 License: MIT """ import math import cv2 import numpy as np from tf_explain.utils.display import grid_display, heatmap_display from tf_explain.utils.saver import save_rgb from...
5,201
31.5125
125
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/atari/highlights_stream_generator.py
""" Generates a stream of gameplay for a given agent. A folder 'stream' is created whose subfolders contain all the states, visually displayed frames, Q-values, saliency maps and features (output of the second to last layer). This module was adapted from a module in https://github.com/HuTobias/HIGHLIG...
5,713
34.271605
149
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/atari/ImageGeneration.py
""" Module for creating example saliency map images for the HIGHLIGHT states. Some functions are adapted from https://github.com/HuTobias/HIGHLIGHTS-LRP Date: 2020 commit: 834bf795ee37a74b611beb79851438e9a8afd676 License: MIT """ import keras import numpy as np from PIL import Image from matplotlib import pyplot as p...
17,546
41.9022
119
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/atari/parameter_search/parameter_test.py
""" Module for testing different parameters for the perturbation-based saliency maps.""" import skimage.segmentation as seg import numpy as np import os import re import keras import timeit import applications.atari.rise as rise from applications.atari.explanation import explainer from applications.atari.custom_lime ...
13,440
43.213816
132
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/atari/parameter_search/Verification/highlights_occlusion_search.py
""" Module for doing a parameter search on different subsets of 10 states of the game Pacman with fast parameter configurations of occlusion. This can then be used to verify which states are suited to search for good parameters.""" import numpy as np import os import re import keras import timeit import applications....
3,958
40.239583
141
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/atari/parameter_search/Verification/full_occlusion_search.py
""" Module for doing a full parameter search for 1000 states of the game Pacman with fast parameter configurations of occlusion. This can then be used to verify which states are suited to search for good parameters. This script needs to be run from the insertion_metric folder, since the insertion results are saved the...
2,839
44.079365
139
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/atari/insertion_metric/insertion_metric_main.py
""" This module does the insertion metric experiments and measures the run-time of the saliency map generation approaches. """ from applications.atari.custom_atari_wrapper import atari_wrapper from applications.atari.explanation import explainer import applications.atari.rise as rise import gym import keras import num...
11,449
45.734694
135
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/atari/sanity_checks/sanity_checks_main.py
''' This module was adapted from a module in https://github.com/HuTobias/HIGHLIGHTS-LRP Date: 2020 commit: 834bf795ee37a74b611beb79851438e9a8afd676 License: MIT This module implements sanity checks for saliency maps. To this end the layers in the model are cascadingly randomized and for each step we create a copy of ...
21,348
41.783567
131
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/affectnet/main_affectnet.py
from applications.affectnet.vgg_face_batch_norm import get_model, get_preprocess import cv2 from applications.atari.explanation import explainer, create_saliency_image import applications.atari.rise as rise import timeit import os import numpy as np from matplotlib import pyplot as plt from skimage.segmentation import ...
8,179
42.743316
124
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/affectnet/vgg_face_batch_norm.py
import os from keras.layers import Dense, GlobalMaxPooling2D, Dropout, Conv2D, MaxPooling2D, BatchNormalization, ZeroPadding2D, Input from keras.models import Model from keras.applications.imagenet_utils import preprocess_input n_output = 8#config.corpus.value # if not config.label_indices else len(config.label_indice...
2,174
30.071429
123
py
PerturbationSaliencyEvaluation
PerturbationSaliencyEvaluation-main/applications/affectnet/generate_no_softmax_model.py
from applications.affectnet.vgg_face_batch_norm import get_model, get_preprocess import keras if __name__ == '__main__': model = get_model() target_size = (224, 224) model.load_weights('vgg_face_batch_norm_e_74_l_1.18.h5') idx_of_layer_to_change = -1 model.layers[idx_of_layer_to_change].activation ...
387
37.8
80
py
Oort
Oort-master/training/testlibs.py
# Standard libs import os, re, shutil, sys, time, datetime, logging, pickle, json, socket import random, math, gc, copy from collections import OrderedDict from ctypes import c_bool from multiprocessing import Process, Value from multiprocessing.managers import BaseManager import multiprocessing, threading import numpy...
1,597
31.612245
138
py
Oort
Oort-master/training/learner.py
# -*- coding: utf-8 -*- from fl_client_libs import * initiate_client_setting() for i in range(torch.cuda.device_count()): try: device = torch.device('cuda:'+str(i)) torch.cuda.set_device(i) logging.info(f'End up with cuda device {torch.rand(1).to(device=device)}') break except ...
26,929
37.252841
174
py
Oort
Oort-master/training/param_server.py
# -*- coding: utf-8 -*- from fl_aggregator_libs import * from random import Random initiate_aggregator_setting() for i in range(torch.cuda.device_count()): try: device = torch.device('cuda:'+str(i)) torch.cuda.set_device(i) logging.info(f'End up with cuda device {torch.rand(1).to(device=de...
23,390
43.810345
164
py
Oort
Oort-master/training/flLibs.py
# Standard libs import os, re, shutil, sys, time, datetime, logging, pickle, json, socket import random, math, gc, copy from collections import OrderedDict from ctypes import c_bool from multiprocessing import Process, Value from multiprocessing.managers import BaseManager import multiprocessing, threading import numpy...
11,520
48.446352
194
py
Oort
Oort-master/training/utils/voice_data_loader.py
import math import os import pickle from tempfile import NamedTemporaryFile import librosa import numpy as np import scipy.signal import soundfile as sf import sox import torch from torch.utils.data import Dataset, Sampler, DistributedSampler, DataLoader from .spec_augment import spec_augment windows = { 'hammin...
14,952
37.940104
120
py
Oort
Oort-master/training/utils/divide_data.py
# -*- coding: utf-8 -*- from random import Random #from core.dataloader import DataLoader from torch.utils.data import DataLoader import numpy as np from math import * import logging from scipy import stats import numpy as np from pyemd import emd from collections import OrderedDict import time import pickle, random fr...
22,021
39.186131
214
py
Oort
Oort-master/training/utils/openImg.py
from __future__ import print_function import warnings from PIL import Image import os import os.path import numpy as np import torch import codecs import string import time class OPENIMG(): """ Args: root (string): Root directory of dataset where ``MNIST/processed/training.pt`` and ``MNIST...
4,302
29.735714
108
py
Oort
Oort-master/training/utils/utils_data.py
# -*- coding: utf-8 -*- import sys from torchvision import transforms def get_data_transform(data: str): if data == 'mnist': train_transform = transforms.Compose([ #transforms.Grayscale(num_output_channels=1), transforms.Resize((28,28)), transforms.RandomHorizontalFlip(), ...
5,916
42.189781
96
py
Oort
Oort-master/training/utils/inception.py
from collections import namedtuple import warnings import torch import torch.nn as nn import torch.nn.functional as F #from torch.jit.annotations import Optional from torch import Tensor __all__ = ['Inception3', 'inception_v3', 'InceptionOutputs', '_InceptionOutputs'] kernel_size = 1 model_urls = { # Inception v...
15,687
36.441527
102
py
Oort
Oort-master/training/utils/resnet_speech.py
"""Imported from https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py and added support for the 1x32x32 mel spectrogram for the speech recognition. Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun: Deep Residual Learning for Image Recognition https://arxiv.org/abs/1512.03385 """ import torch.nn...
6,915
30.294118
95
py
Oort
Oort-master/training/utils/stackoverflow.py
from __future__ import print_function import warnings import os import os.path import torch import time import pickle import h5py as h5 import torch.nn.functional as F #import logging class stackoverflow(): """ Args: root (string): Root directory of dataset where ``MNIST/processed/training.pt`` ...
8,611
34.73444
162
py
Oort
Oort-master/training/utils/femnist.py
from __future__ import print_function import warnings from PIL import Image import os import os.path import numpy as np import torch import codecs import string import time import pickle class FEMNIST(): """ Args: root (string): Root directory of dataset where ``MNIST/processed/training.pt`` ...
3,678
28.432
95
py
Oort
Oort-master/training/utils/spec_augment.py
# Copyright 2019 RnD at Spoon Radio # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wr...
4,866
36.152672
127
py
Oort
Oort-master/training/utils/nlp.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...
37,352
42.132794
165
py
Oort
Oort-master/training/utils/yogi.py
import torch class YoGi(): def __init__(self, eta=1e-2, tau=1e-3, beta=0.999, beta2=-1): self.eta = eta self.tau = tau self.beta = beta self.v_t = [] self.m_t = [] self.beta2 = beta2 def update(self, gradients): update_gradients = [] for idx, gr...
1,310
31.775
126
py
Oort
Oort-master/training/utils/sparse_image_warp.py
# Copyright 2019 RnD at Spoon Radio # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wr...
16,253
38.547445
113
py
Oort
Oort-master/training/utils/dataloaders.py
from torch.utils.data import Dataset import torch import os import pandas as pd # This loader works for Amazon/Yelp Review class TextSentimentDataset(Dataset): def __init__(self, data_path, max_len, train=True, tokenizer=None): file = 'training.csv' if train else 'testing.csv' self.df = pd.read_c...
2,226
34.919355
100
py
Oort
Oort-master/training/utils/utils_model.py
# -*- coding: utf-8 -*- import math import random import torch import torch.nn as nn import torch.optim as optim from torch.autograd import Variable import numpy as np import logging from argParser import args from utils.nlp import mask_tokens from utils.decoder import GreedyDecoder class MySGD(optim.SGD): def ...
10,219
33.295302
126
py
Oort
Oort-master/training/utils/decoder.py
#!/usr/bin/env python # ---------------------------------------------------------------------------- # Copyright 2015-2016 Nervana Systems Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at #...
8,145
40.141414
120
py
Oort
Oort-master/training/utils/reddit.py
from __future__ import print_function import warnings import os import os.path import torch import glob import time import json import pickle import torch.nn.functional as F class reddit(): classes = [] MAX_SEQ_LEN = 20000 @property def train_labels(self): warnings.warn("train_labels has been ...
6,070
30.78534
166
py
Oort
Oort-master/training/utils/models.py
# -*- coding: utf-8 -*- import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import math from transformers import BertModel class MnistCNN(nn.Module): """ CNN Network architecture. """ def __init__(self): super(MnistCNN, self).__init__() self.c...
23,019
32.902798
130
py
Oort
Oort-master/training/utils/speech.py
from __future__ import print_function import warnings import os import os.path import numpy as np import torch import codecs import string import time import numba import librosa from torch.utils.data import Dataset CLASSES = ['up', 'two', 'sheila', 'zero', 'yes', 'five', 'one', 'happy', 'marvin', 'no', 'go', 'seven',...
5,615
31.091429
295
py
Oort
Oort-master/training/utils/mobilenet.py
from torch import nn import torch.utils.model_zoo as model_zoo __all__ = ['MobileNetV2', 'mobilenet_v2'] model_urls = { 'mobilenet_v2': 'https://download.pytorch.org/models/mobilenet_v2-b0353104.pth', } def _make_divisible(v, divisor, min_value=None): """ This function is taken from the original tf re...
6,560
35.653631
107
py
Oort
Oort-master/training/utils/transforms_stft.py
"""Transforms on the short time fourier transforms of wav samples.""" __author__ = 'Erdene-Ochir Tuguldur' import random import numpy as np import librosa from torch.utils.data import Dataset from .transforms_wav import should_apply_transform random.seed(233) class ToSTFT(object): """Applies on an audio the ...
4,134
30.325758
121
py