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
AgML
AgML-main/experiments/benchmarking/classification_distributed.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
6,726
31.814634
83
py
AgML
AgML-main/experiments/benchmarking/detection_lightning_local.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
26,638
37.607246
107
py
AgML
AgML-main/experiments/benchmarking/miou_evaluation.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
3,988
31.169355
91
py
AgML
AgML-main/experiments/benchmarking/detection_modeling.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
8,868
41.845411
96
py
AgML
AgML-main/experiments/benchmarking/classification_lightning_resnet50.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
9,011
33.136364
90
py
AgML
AgML-main/agml/models/base.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
6,551
33.851064
96
py
AgML
AgML-main/agml/models/classification.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
8,921
40.887324
81
py
AgML
AgML-main/agml/models/losses.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
2,104
34.677966
74
py
AgML
AgML-main/agml/models/preprocessing.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
8,321
41.676923
85
py
AgML
AgML-main/agml/models/segmentation.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
14,006
42.231481
86
py
AgML
AgML-main/agml/models/tools.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
4,452
32.734848
103
py
AgML
AgML-main/agml/models/__init__.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
1,690
37.431818
90
py
AgML
AgML-main/agml/models/detection.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
22,088
41.397313
87
py
AgML
AgML-main/agml/models/metrics/accuracy.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
2,632
38.298507
84
py
AgML
AgML-main/agml/models/metrics/map.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
9,795
39.147541
85
py
AgML
AgML-main/agml/backend/random.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
983
32.931034
74
py
AgML
AgML-main/agml/backend/tftorch.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
10,087
33.081081
104
py
AgML
AgML-main/agml/backend/__init__.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
1,371
33.3
76
py
AgML
AgML-main/agml/viz/labels.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
5,095
38.8125
87
py
AgML
AgML-main/agml/viz/tools.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
6,828
31.061033
82
py
AgML
AgML-main/agml/viz/general.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
4,786
35.823077
87
py
AgML
AgML-main/agml/utils/general.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
4,734
29.352564
94
py
AgML
AgML-main/agml/data/object.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
9,127
36.875519
86
py
AgML
AgML-main/agml/data/tools.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
7,351
39.395604
84
py
AgML
AgML-main/agml/data/experimental.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
3,748
34.704762
77
py
AgML
AgML-main/agml/data/manager.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
16,197
41.626316
94
py
AgML
AgML-main/agml/data/loader.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
75,355
43.828079
90
py
AgML
AgML-main/agml/data/multi_loader.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
66,025
42.639128
94
py
AgML
AgML-main/agml/data/managers/transform_helpers.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
6,074
36.5
76
py
AgML
AgML-main/agml/data/managers/training.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
15,928
40.481771
82
py
AgML
AgML-main/agml/data/managers/transforms.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
26,516
48.288104
89
py
AgML
AgML-main/agml/data/exporters/tensorflow.py
# Copyright 2021 UC Davis Plant AI and Biophysics Lab # # 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 ...
9,639
38.02834
79
py
NeLLoC
NeLLoC-main/utils.py
''' Code by Hrituraj Singh Indian Institute of Technology Roorkee ''' from torchvision import datasets, transforms import configparser import os import torch.nn.functional as F import torch import numpy as np import matplotlib.pyplot as plt from torch.autograd import Variable from torch.nn.utils import weight_norm as ...
6,542
29.863208
96
py
NeLLoC
NeLLoC-main/model.py
import torch.nn as nn import torch import torch.nn.functional as F class MaskedCNN(nn.Conv2d): def __init__(self, mask_type, *args, **kwargs): self.mask_type = mask_type assert mask_type in ['A', 'B'], "Unknown Mask Type" super(MaskedCNN, self).__init__(*args, **kwargs) self.regi...
2,366
31.875
116
py
NeLLoC
NeLLoC-main/train.py
import os import torch from torch import optim from torch.utils import data import torch.nn as nn from model import * import numpy as np import torchvision import torch.nn.functional as F from torch.optim import lr_scheduler from torchvision import datasets, transforms from torch.autograd import Variable from utils imp...
2,146
26.883117
118
py
NeLLoC
NeLLoC-main/coder/distributions.py
import torch import numpy as np rescaling = lambda x : (x - .5) * 2. rescaling_inv = lambda x : .5 * x + .5 def discretized_mix_logistic_cdftable(means, log_scales,pi, alpha=0.0001): x=rescaling(torch.arange(0,256)/255.).view(256,1).repeat(1,10).to(means.device) centered_x = x - means inv_stdv = torc...
1,553
33.533333
83
py
NeLLoC
NeLLoC-main/coder/ans_coder.py
from coder.distributions import * import numpy as np class ANSStack(object): def __init__(self, s_prec , t_prec, p_prec): self.s_prec=s_prec self.t_prec=t_prec self.p_prec=p_prec self.t_mask = (1 << t_prec) - 1 self.s_min=1 << s_prec - t_prec self.s_max=1 << s_prec...
4,241
36.875
137
py
NeLLoC
NeLLoC-main/coder/ac_coder.py
from model import * from decimal import * from coder.distributions import * tensor2decimal= lambda x : Decimal(str(x.cpu().item())) def bin_2_float(binary): prob = Decimal('0.0') cur_prob=Decimal('0.5') for i in binary: prob=prob+cur_prob* int(i) cur_prob*=Decimal('0.5') ret...
4,462
33.596899
103
py
NeLLoC
NeLLoC-main/batch_coder/distributions.py
import torch import numpy as np rescaling = lambda x : (x - .5) * 2. rescaling_inv = lambda x : .5 * x + .5 def discretized_mix_logistic_cdftable(means, log_scales,pi, alpha=0.0001): bs=means.size(0) pi=pi.unsqueeze(1) x=rescaling(torch.arange(0,256)/255.).view(1,256,1).repeat(bs,1,10) centered_...
2,159
35
115
py
NeLLoC
NeLLoC-main/batch_coder/ians_coder.py
import torch import numpy as np from batch_coder.distributions import * s_prec = 64 t_prec = 32 t_mask = (1 << t_prec) - 1 s_min = 1 << s_prec - t_prec s_max = 1 << s_prec s_prec_u,t_prec_u=np.uint8(s_prec),np.uint8(t_prec) def get_length(s,t_stack): return ((len(t_stack))*t_prec+sum(len(bin(i)) for i in s...
4,562
37.025
150
py
onnx
onnx-main/docs/docsgen/source/conf.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 # pylint: disable=W0622 # type: ignore import os import sys import warnings import onnx sys.path.append(os.path.abspath(os.path.dirname(__file__))) # -- Project information ----------------------------------------------------- autho...
3,121
24.590164
125
py
onnx
onnx-main/onnx/tools/net_drawer.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # A library and utility for drawing ONNX nets. Most of this implementation has # been borrowed from the caffe2 implementation # https://github.com/pytorch/pytorch/blob/master/caffe2/python/net_drawer.py # # The script takes two required ar...
4,901
30.625806
86
py
onnx
onnx-main/onnx/reference/ops/op_lp_pool.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=W0221,R0913,R0914 import numpy as np from onnx.reference.ops._op_common_pool import CommonPool class LpPool(CommonPool): def _run( # type: ignore self, x, auto_pad=None, ceil_mode=...
1,216
27.97619
119
py
onnx
onnx-main/onnx/reference/ops/op_hamming_window.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=W0221 import numpy as np from onnx.reference.ops._op_common_window import _CommonWindow class HammingWindow(_CommonWindow): """ Returns :math:`\\omega_n = \\alpha - \\beta \\cos \\left( \\frac{\\pi n}{N-1}...
811
29.074074
83
py
onnx
onnx-main/onnx/reference/ops/op_hann_window.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=W0221 import numpy as np from onnx.reference.ops._op_common_window import _CommonWindow class HannWindow(_CommonWindow): """ Returns :math:`\\omega_n = \\sin^2\\left( \\frac{\\pi n}{N-1} \\right)` wher...
690
27.791667
78
py
onnx
onnx-main/onnx/reference/ops/op_col2im.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=R0913,R0914,W0221 import numpy as np from onnx.reference.op_run import OpRun from onnx.reference.ops._op_common_indices import _get_indices, _is_out def _col2im_shape_check_2d(X, output_shape, kernel_shape, dilations,...
8,046
37.319048
123
py
onnx
onnx-main/onnx/reference/ops/op_resize.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=C0123,C3001,R0912,R0913,R0914,R1730,W0221,W0613 from typing import Any, Callable, List, Optional, Tuple import numpy as np from onnx.reference.op_run import OpRun def _cartesian( arrays: List[np.ndarray], out: Op...
15,638
32.274468
102
py
onnx
onnx-main/onnx/reference/ops/op_stft.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=R0913,R0914,R0915,W0613,W0221 import numpy as np from onnx.reference.op_run import OpRun from onnx.reference.ops.op_concat_from_sequence import _concat_from_sequence from onnx.reference.ops.op_dft import _cfft as _dft f...
5,591
31.511628
97
py
onnx
onnx-main/onnx/reference/ops/op_blackman_window.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=W0221 import numpy as np from onnx.reference.ops._op_common_window import _CommonWindow class BlackmanWindow(_CommonWindow): """ Returns :math:`\\omega_n = 0.42 - 0.5 \\cos \\left( \\frac{2\\pi n}{N-1} \\...
932
27.272727
79
py
onnx
onnx-main/onnx/reference/ops/op_grid_sample.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # pylint: disable=R0912,R0913,R0914,R0915,R1702,R1716,W0221 import numbers from typing import List import numpy as np from onnx.reference.op_run import OpRun from onnx.reference.ops.op_resize import _get_all_coords class GridSample(Op...
13,472
35.217742
108
py
onnx
onnx-main/onnx/backend/test/case/node/gridsample.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect class GridSample(Base): @staticmethod def export_gridsample() -> None: node = onnx.helper.make_...
19,682
29.658879
87
py
onnx
onnx-main/onnx/backend/test/case/node/resize.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect from onnx.reference.ops.op_resize import _cubic_coeffs as cubic_coeffs from onnx.reference.ops.op_resize import (...
51,616
29.114936
104
py
onnx
onnx-main/onnx/backend/test/runner/__init__.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import functools import glob import os import re import shutil import sys import tarfile import tempfile import time import unittest from collections import defaultdict from typing import Any, Callable...
19,487
39.181443
104
py
onnx
onnx-main/onnx/test/reference_evaluator_test.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # type: ignore # pylint: disable=C3001,C0302,C0415,R0904,R0913,R0914,R0915,W0221,W0707 """ You can run a specific test by using the following syntax. :: python onnx/test/reference_evaluator_test.py TestReferenceEvaluator.test_functio...
145,760
37.469517
115
py
onnx
onnx-main/onnx/test/reference_evaluator_backend_test.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 # type: ignore # pylint: disable=C0415,R0912,R0913,R0914,R0915,W0613,W0640,W0703 """ These test evaluates the python runtime (class ReferenceEvaluator) against all the backend tests (in onnx/backend/test/case/node) and checks the runtime p...
34,178
38.106407
127
py
adagrid
adagrid-main/uniform-negative-sampling/adagrid_uniform_negative_sampling.py
from pathlib import Path import torch.multiprocessing torch.multiprocessing.set_sharing_strategy('file_system') import argparse import copy import math import random import numpy as np import pandas as pd from sklearn.metrics import * import torch import torch.nn.functional as F from torch.utils.data import DataLoade...
14,995
30.241667
132
py
adagrid
adagrid-main/community-ratio-based-negative-sampling/adagrid_community_ratio_based_negative_sampling.py
from pathlib import Path import torch.multiprocessing torch.multiprocessing.set_sharing_strategy('file_system') import argparse import copy import math import random import numpy as np import pandas as pd from sklearn.metrics import * import torch import torch.nn.functional as F from torch.utils.data import DataLoade...
19,954
30.979167
132
py
SMERF
SMERF-main/scripts/adv_train.py
""" This is an example of how to use ART and Keras to perform adversarial training using data generators for CIFAR10 """ import keras import numpy as np from keras.layers import Conv2D, Dense, Flatten, MaxPooling2D, Input, BatchNormalization from keras.models import Model from keras.preprocessing.image import ImageData...
9,861
43.224215
128
py
SMERF
SMERF-main/smerf/explanations.py
import numpy as np import imp textcolorutils = imp.load_source('textcolor_utils', '../smerf/textcolor_utils.py') import innvestigate import keras import keras.backend as K import tensorflow as tf import cv2 import pickle import os from tqdm import tqdm # NOTE Helper functions for saliency methods that are not support...
13,998
45.97651
156
py
SMERF
SMERF-main/smerf/grad_cam_utils.py
""" Source code adapted from https://github.com/wawaku/grad-cam-keras """ from keras.preprocessing import image from tensorflow.python.framework import ops import keras.backend as K import tensorflow as tf import numpy as np import keras import cv2 import os, gc from .models import TextBoxCNN as TextBoxCNN from .mode...
5,486
33.727848
117
py
SMERF
SMERF-main/smerf/shap_utils.py
import shap import tensorflow as tf import keras.backend as K import numpy as np from smerf.models import * import gc # Uses SHAP library to obtain feature attributions def shap_run(model, x_sample, y_sample, x_train, exp_no, model_type): ## NOTE due to complications in keras and TF versions (this code works only ...
1,980
40.270833
97
py
SMERF
SMERF-main/smerf/textbox_data.py
import numpy as np import PIL from PIL import Image, ImageDraw, ImageFont, ImageEnhance from torch.utils.data import Dataset, DataLoader import os from smerf.eval import setup_bboxes import pickle DATA_DIR = '../data/' class TextBoxDataset(Dataset): def __init__(self, X, y): self.X = X self.y = y ...
9,823
38.773279
200
py
SMERF
SMERF-main/smerf/models.py
import keras from keras.layers.pooling import GlobalAveragePooling1D, GlobalAveragePooling2D import numpy as np from keras.utils.np_utils import to_categorical import os import keras.backend as K from keras.callbacks import EarlyStopping, ModelCheckpoint from keras.metrics import categorical_accuracy from keras.applica...
10,558
45.928889
159
py
SMERF
SMERF-main/smerf/lime_utils.py
import lime from lime import lime_image from lime.wrappers.scikit_image import SegmentationAlgorithm import tensorflow as tf import keras.backend as K import numpy as np from smerf.models import * # Uses LIME library to obtain feature attributions def lime_run(model, x_sample, y_sample, x_train, exp_no): n, h, w, ...
1,723
45.594595
101
py
cpnest
cpnest-master/docs/conf.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # CPNest documentation build configuration file, created by # sphinx-quickstart on Thu Dec 7 13:57:03 2017. # # 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 # aut...
5,836
30.896175
85
py
CR-VAE
CR-VAE-main/CRVAE_demo.py
# -*- coding: utf-8 -*- """ Created on Sat Aug 6 20:00:04 2022 @author: 61995 """ import torch import numpy as np import matplotlib.pyplot as plt from models.cgru_error import CRVAE, VRAE4E, train_phase1, train_phase2 import scipy.io device = torch.device('cuda') X_np = np.load('henon.npy').T dim = X_np.shape[-...
2,116
23.333333
99
py
CR-VAE
CR-VAE-main/models/cgru_error.py
# -*- coding: utf-8 -*- """ Created on Sat Aug 6 20:01:33 2022 @author: 61995 """ import torch import torch.nn as nn import numpy as np from copy import deepcopy import matplotlib.pyplot as plt from metrics.visualization_metrics import visualization import torch.optim as optim class GRU(nn.Module): def __init_...
20,309
30.734375
132
py
ulysses
ulysses-master/doc/conf.py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
5,441
28.737705
79
py
Tatoeba-Challenge
Tatoeba-Challenge-master/scripts/convert_marian_tatoeba_to_pytorch.py
# Copyright 2020 The HuggingFace Team. 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 copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
34,591
25.94081
175
py
defend_framework
defend_framework-main/DPA_certified_train.py
import torch import os import json import time import numpy as np from utils.data_processing import MNIST17DataPreprocessor, MNISTDataPreprocessor, IMDBDataPreprocessor, \ EmberDataPreProcessor, EMBER_DATASET, EmberPoisonDataPreProcessor, MNIST01DataPreprocessor, \ MNIST17LimitedDataPreprocessor, FMNISTDataPr...
2,833
39.485714
115
py
defend_framework
defend_framework-main/gen_attack_dataset.py
import random import os import json import time import numpy as np import tensorflow as tf from tensorflow import keras from utils.data_processing import MNISTDataPreprocessor, MNIST17DataPreprocessor, MNIST01DataPreprocessor, \ CIFAR02DataPreprocessor from models.MNISTModel import MNISTModel, MNIST17Model, MNIST...
5,498
42.642857
118
py
defend_framework
defend_framework-main/models/LiRPAModel.py
from abc import ABC, abstractmethod from torch.utils.data import TensorDataset, DataLoader import torch.optim as optim from torch.nn import CrossEntropyLoss from auto_LiRPA import BoundedModule, BoundedTensor from auto_LiRPA.perturbations import * from auto_LiRPA.eps_scheduler import LinearScheduler, AdaptiveScheduler...
12,734
53.191489
123
py
defend_framework
defend_framework-main/models/EmberLiRPAModel.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from models.LiRPAModel import LiRPAModel class EmberModel(LiRPAModel): def __init__(self, n_features, n_classes, args, device, lr=1e-3): super(EmberModel, self).__init__([1, 1, n_features], n_classes, args, device, mlp_...
1,310
30.214286
112
py
defend_framework
defend_framework-main/models/MNISTModel.py
from tensorflow import keras from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Flatten, Dropout from tensorflow.keras.layers import Conv2D, AveragePooling2D, MaxPooling2D from tensorflow.keras.regularizers import l2 from models.Model import Model class MNISTModel(Model): d...
4,251
38.37037
94
py
defend_framework
defend_framework-main/models/MNISTLiRPAModel.py
from torchvision import transforms import torch.nn as nn import torch.nn.functional as F import numpy as np from models.LiRPAModel import LiRPAModel class MNISTModel(LiRPAModel): def __init__(self, n_features, n_classes, args, device, lr=1e-3): super(MNISTModel, self).__init__(n_features, n_classes, args...
1,294
30.585366
93
py
defend_framework
defend_framework-main/models/Model.py
from abc import ABC, abstractmethod import os import numpy as np from tensorflow.keras.models import load_model class Model(ABC): def __init__(self, input_shape, n_classes, lr): self.input_shape = input_shape self.n_classes = n_classes self.lr = lr self.callback = None sel...
1,351
30.44186
113
py
defend_framework
defend_framework-main/models/IMDBTransformerModel.py
import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from models.Model import Model class TransformerBlock(layers.Layer): def __init__(self, embed_dim, num_heads, ff_dim, rate=0.1): super(TransformerBlock, self).__init__() self.att = layers.MultiHeadAttention(n...
2,535
38.015385
84
py
defend_framework
defend_framework-main/models/EmberModel.py
from tensorflow import keras from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Input, Dropout, BatchNormalization, Activation from tensorflow.keras.layers import Conv2D, AveragePooling2D from tensorflow.keras.regularizers import l2 from models.Model import Model class EmberMod...
2,009
36.924528
95
py
defend_framework
defend_framework-main/models/CIFAR10Model.py
from tensorflow import keras from tensorflow.keras.layers import BatchNormalization, Activation, Conv2D, Input, AveragePooling2D, Flatten, Dense from tensorflow.keras.regularizers import l2 from tensorflow.keras.optimizers import Adam import numpy as np from tensorflow.keras.callbacks import LearningRateScheduler, Redu...
6,009
33.342857
115
py
defend_framework
defend_framework-main/utils/dataaug.py
from tensorflow.keras.preprocessing.image import ImageDataGenerator from tensorflow import keras import numpy as np import torch from torchvision import transforms def DataGeneratorForMNIST(): datagen = ImageDataGenerator( # set input mean to 0 over the dataset featurewise_center=False, # ...
5,425
38.318841
119
py
defend_framework
defend_framework-main/utils/data_processing.py
import os import pickle import numpy as np from tensorflow.keras.datasets import mnist, imdb, cifar10, fashion_mnist from tensorflow import keras import ember import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler, KBinsDiscretizer, MinMaxScaler from ...
29,834
46.132701
118
py
defend_framework
defend_framework-main/utils/train_utils.py
import numpy as np from tensorflow import keras from tqdm import trange import os from utils.dataaug import DataGeneratorForMNIST, MNISTDataGenerator, EmberDataGenerator, CIFARDataGenerator from utils import EMBER_DATASET, IMAGE_DATASET def train_many(data_loader, model, args, aggregate_result, aggregate_noise_resul...
4,535
50.545455
120
py
secml-zoo
secml-zoo-master/models/mnist/mnist_cnn.py
""" .. module:: MNISTCNN :synopsis: A CNN model for MNIST .. moduleauthor:: Ambra Demontis <ambra.demontis@diee.unica.it> """ from collections import OrderedDict import torch from torch import nn, optim from secml.ml.classifiers import CClassifierPyTorch class Flatten(nn.Module): def __init__(self): ...
6,209
36.409639
88
py
secml-zoo
secml-zoo-master/models/mnist/mnist3c_cnn.py
""" .. module:: MNIST3cCNN :synopsis: CNN to be trained on MNIST 3-classes dataset .. moduleauthor:: Maura Pintor <maura.pintor@unica.it> .. moduleauthor:: Marco Melis <marco.melis@unica.it> """ import torch from torch import nn, optim from secml.ml.classifiers import CClassifierPyTorch class MNIST3cCNN(nn.Modu...
1,486
29.346939
75
py
secml-zoo
secml-zoo-master/models/iCubWorld/utils.py
import numpy as np from secml.array import CArray from secml.ml import CNormalizerDNN from .alexnet import alexnet def attach_alexnet(clf): """Attach AlexNet (as a preprocessor) to input CClassifier. The output of `classifier:4` layer is used as input for the classifier. """ clf.preprocess = CNor...
1,021
30.9375
76
py
secml-zoo
secml-zoo-master/models/iCubWorld/alexnet.py
""" .. module:: AlexNet :synopsis: AlexNet Convolutional Neural Network .. moduleauthor:: Marco Melis <marco.melis@unica.it> """ from torchvision import models from secml.ml.classifiers import CClassifierPyTorch from secml.ml.features.normalization import CNormalizerMeanStd def alexnet(): """CClassifierPyTo...
803
27.714286
79
py
secml-zoo
secml-zoo-master/models/iCubWorld/iCubWorld28/tests/test_models_icubworld28.py
from models.iCubWorld.tests import CICubWorldTestCases from secml.ml.classifiers.multiclass import CClassifierMulticlassOVA from secml.utils import fm, pickle_utils from models.iCubWorld.utils import ds_numpy_to_pytorch class TestModelsICubWorld28(CICubWorldTestCases): """Unittests for iCubWorld28 models.""" ...
1,080
29.027778
73
py
secml-zoo
secml-zoo-master/models/iCubWorld/iCubWorld28/_exporters/icubworld28-day4-svm.py
import sys sys.path.insert(0, '../../../') from svm_ova import svm_ova from iCubWorld.utils import attach_alexnet, ds_numpy_to_pytorch from secml.data.loader import CDataLoaderICubWorld28 from secml.data.splitter import CDataSplitter from secml.ml.peval.metrics import CMetricAccuracy dl = CDataLoaderICubWorld28() dl...
1,418
20.5
76
py
secml-zoo
secml-zoo-master/models/iCubWorld/iCubWorld28/_exporters/icubworld28-day4-svm-rbf.py
import sys sys.path.insert(0, '../../../') from svm_rbf_ova import svm_rbf_ova from iCubWorld.utils import attach_alexnet, ds_numpy_to_pytorch from secml.data.loader import CDataLoaderICubWorld28 from secml.data.splitter import CDataSplitter from secml.ml.peval.metrics import CMetricAccuracy dl = CDataLoaderICubWorl...
1,536
21.602941
78
py
secml-zoo
secml-zoo-master/models/iCubWorld/iCubWorld7/tests/test_models_icubworld7.py
from models.iCubWorld.tests import CICubWorldTestCases from secml.ml.classifiers.multiclass import CClassifierMulticlassOVA from secml.utils import fm, pickle_utils from models.iCubWorld.utils import ds_numpy_to_pytorch class TestModelsICubWorld7(CICubWorldTestCases): """Unittests for iCubWorld7 models.""" ...
1,074
28.861111
73
py
secml-zoo
secml-zoo-master/models/iCubWorld/iCubWorld7/_exporters/icubworld7-day4-svm.py
import sys sys.path.insert(0, '../../../') from svm_ova import svm_ova from iCubWorld.utils import attach_alexnet, ds_numpy_to_pytorch from secml.data.loader import CDataLoaderICubWorld28 from secml.data.splitter import CDataSplitter from secml.ml.peval.metrics import CMetricAccuracy dl = CDataLoaderICubWorld28() dl...
1,439
20.818182
76
py
secml-zoo
secml-zoo-master/models/iCubWorld/iCubWorld7/_exporters/icubworld7-day4-svm-rbf.py
import sys sys.path.insert(0, '../../../') from svm_rbf_ova import svm_rbf_ova from iCubWorld.utils import attach_alexnet, ds_numpy_to_pytorch from secml.data.loader import CDataLoaderICubWorld28 from secml.ml.peval.metrics import CMetricAccuracy dl = CDataLoaderICubWorld28() dl.verbose = 2 tr = dl.load( ds_typ...
1,513
21.597015
78
py
ActiveLearningForHumanPose
ActiveLearningForHumanPose-main/code/main.py
import os import copy import logging import cv2 import numpy as np import pandas as pd from tqdm import tqdm from matplotlib import pyplot as plt import torch import torch.utils.data from torch.utils.tensorboard import SummaryWriter from torch.optim.lr_scheduler import ReduceLROnPlateau as ReduceLROnPlateau from con...
41,564
42.342023
168
py
ActiveLearningForHumanPose
ActiveLearningForHumanPose-main/code/activelearning.py
import os import cv2 import torch import torch.utils.data import numpy as np import logging from tqdm import tqdm from pathlib import Path from sklearn.metrics import pairwise_distances from skimage.feature import peak_local_max from scipy.special import softmax as softmax_fn from scipy.stats import entropy as entropy_...
43,791
39.774674
160
py
ActiveLearningForHumanPose
ActiveLearningForHumanPose-main/code/dataloader.py
import os import copy import logging from pathlib import Path import cv2 import scipy.io import numpy as np from tqdm import tqdm from matplotlib import pyplot as plt from matplotlib.patches import Circle import torch import torch.utils.data import albumentations as albu from utils import heatmap_generator from util...
52,432
41.182623
137
py
ActiveLearningForHumanPose
ActiveLearningForHumanPose-main/code/utils.py
import os import sys import copy import math from pathlib import Path import torch import scipy.io import numpy as np from tqdm import tqdm from adjustText import adjust_text from matplotlib import pyplot as plt from matplotlib.patches import Circle, Rectangle import umap from sklearn.decomposition import PCA plt.st...
14,742
36.513995
130
py
ActiveLearningForHumanPose
ActiveLearningForHumanPose-main/code/activelearning_viz.py
import os import cv2 import math import torch import torch.utils.data import numpy as np import logging from tqdm import tqdm from pathlib import Path from sklearn.metrics import pairwise_distances from skimage.feature import peak_local_max from scipy.special import softmax as softmax_fn from scipy.stats import entropy...
89,213
43.056296
162
py
ActiveLearningForHumanPose
ActiveLearningForHumanPose-main/code/autograd_hacks.py
""" Credits: https://github.com/cybertronai/autograd-hacks Library for extracting interesting quantites from autograd, see README.md Not thread-safe because of module-level variables Notation: o: number of output classes (exact Hessian), number of Hessian samples (sampled Hessian) n: batch-size do: output dimension (...
9,972
33.628472
133
py
ActiveLearningForHumanPose
ActiveLearningForHumanPose-main/code/models/stacked_hourglass/StackedHourglass.py
''' Baseline Architecture: Stacked Hourglass https://github.com/princeton-vl/pytorch_stacked_hourglass ''' import torch from torch import nn from .layers import Conv, Hourglass, Pool, Residual class Merge(nn.Module): ''' ''' def __init__(self, x_dim, y_dim): super(Merge, self).__init__() ...
5,127
40.024
122
py
ActiveLearningForHumanPose
ActiveLearningForHumanPose-main/code/models/stacked_hourglass/layers.py
import torch from torch import nn Pool = nn.MaxPool2d def batchnorm(x): return nn.BatchNorm2d(x.size()[1])(x) class Conv(nn.Module): ''' Initializes: Conv, Conv-Relu or Conv-Relu-BN combinaton ''' def __init__(self, inp_dim, out_dim, kernel_size, stride=1, bn=False, relu=True): ''' ...
4,697
31.625
114
py