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 |
|---|---|---|---|---|---|---|
GANSeg | GANSeg-main/models/sync_batchnorm/batchnorm.py | # -*- coding: utf-8 -*-
# File : batchnorm.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import collections
import contextlib
import... | 16,021 | 38.463054 | 115 | py |
GANSeg | GANSeg-main/models/sync_batchnorm/batchnorm_reimpl.py | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# File : batchnorm_reimpl.py
# Author : acgtyrant
# Date : 11/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import torch
import torch.nn as nn
import torch... | 2,359 | 30.466667 | 95 | py |
GANSeg | GANSeg-main/datasets/datasets.py | import torch
from torchvision import datasets, transforms
import torch.utils.data
import matplotlib.pyplot as plt
import numpy as np
import torch
import os
from PIL import Image
import torchvision
import h5py
import pandas
class CelebAWildTrain(torch.utils.data.Dataset):
def __init__(self, data_root, image_size):... | 11,538 | 36.343042 | 118 | py |
toothless | toothless-master/Codes/fusion-classify.py | ## Fusion Model classification
# Arun Aniyan
# SKA SA/ RATT
# arun@ska.ac.za
# 18-02-17
# Input can be either fits image or jpg/png
# Import necessary stuff
import sys
import os
import time
import datetime
from collections import Counter
import PIL.Image
import numpy as np
import scipy.misc
from google.protobuf imp... | 10,556 | 27.077128 | 105 | py |
cleanvision | cleanvision-main/src/cleanvision/imagelab.py | """
Imagelab is the core class in CleanVision for finding all types of issues in an image dataset.
The methods in this module should suffice for most use-cases,
but advanced users can get extra flexibility via the code in other CleanVision modules.
"""
from __future__ import annotations
import random
from typing impor... | 27,057 | 38.157742 | 177 | py |
cleanvision | cleanvision-main/src/cleanvision/dataset/base_dataset.py | from __future__ import annotations
from collections.abc import Sized
from typing import List, Union
from PIL import Image
class Dataset(Sized):
"""Wrapper class to handle datasets loaded from various sources like: image files in a local folder, huggingface, or torchvision."""
def __init__(self) -> None:
... | 978 | 31.633333 | 136 | py |
cleanvision | cleanvision-main/src/cleanvision/dataset/utils.py | from __future__ import annotations
from typing import List, Optional, TYPE_CHECKING
from cleanvision.dataset.base_dataset import Dataset
from cleanvision.dataset.folder_dataset import FolderDataset
from cleanvision.dataset.hf_dataset import HFDataset
from cleanvision.dataset.torch_dataset import TorchDataset
if TYPE... | 1,184 | 33.852941 | 142 | py |
cleanvision | cleanvision-main/src/cleanvision/dataset/torch_dataset.py | from __future__ import annotations
from typing import TYPE_CHECKING, Union
from PIL import Image
from cleanvision.dataset.base_dataset import Dataset
if TYPE_CHECKING: # pragma: no cover
from torchvision.datasets.vision import VisionDataset
class TorchDataset(Dataset):
"""Wrapper class to handle datasets... | 1,019 | 27.333333 | 67 | py |
cleanvision | cleanvision-main/tests/test_dataset.py | import os
import torchvision
from datasets import load_dataset
from cleanvision.dataset.folder_dataset import FolderDataset
from cleanvision.dataset.hf_dataset import HFDataset
from cleanvision.dataset.torch_dataset import TorchDataset
from cleanvision.dataset.utils import build_dataset
class TestDataset:
def t... | 1,969 | 40.041667 | 88 | py |
cleanvision | cleanvision-main/tests/conftest.py | import matplotlib.pyplot as plt
import numpy as np
import pytest
from PIL import Image
from datasets import load_dataset
import torchvision
@pytest.fixture(scope="session")
def n_classes():
return 4
@pytest.fixture(scope="session")
def images_per_class():
return 10
@pytest.fixture(scope="session")
def len... | 2,367 | 27.878049 | 85 | py |
cleanvision | cleanvision-main/tests/test_visualize.py | import random
from unittest.mock import patch
import pytest
from PIL import Image
import cleanvision
from cleanvision import Imagelab
from cleanvision.utils.utils import get_filepaths
@pytest.fixture()
def folder_imagelab(generate_local_dataset):
imagelab = Imagelab(data_path=generate_local_dataset)
return ... | 4,190 | 28.935714 | 88 | py |
cleanvision | cleanvision-main/tests/test_run.py | import os
from pathlib import Path
import numpy as np
import pytest
from PIL import Image
from cleanvision import Imagelab
from cleanvision.dataset.folder_dataset import FolderDataset
from cleanvision.issue_managers.image_property import BrightnessProperty
from cleanvision.issue_managers.image_property_issue_manager ... | 10,061 | 34.55477 | 138 | py |
cleanvision | cleanvision-main/docs/source/tutorials/run.py | import argparse
from cleanvision import Imagelab
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Demonstrates how to use Imagelab")
parser.add_argument("--path", type=str, help="path to dataset", required=True)
args = parser.parse_args()
dataset_path = args.path
"""
... | 4,804 | 32.368056 | 157 | py |
predictive-forward-forward | predictive-forward-forward-main/src/sim_train.py | """
Code for paper "The Predictive Forward-Forward Algorithm" (Ororbia & Mali, 2022)
################################################################################
Simulates the training/adaptation of a recurrent neural system composed of
a representation and generative circuit, trained via the preditive forward-for... | 11,570 | 33.335312 | 160 | py |
predictive-forward-forward | predictive-forward-forward-main/src/pff_rnn.py | """
Code for paper "The Predictive Forward-Forward Algorithm" (Ororbia & Mali, 2022)
This file contains model constructor and its credit assignment code.
"""
import os
import sys
import copy
import pickle
#import dill as pickle
import tensorflow as tf
import numpy as np
### generic routines/functions
def serialize(... | 22,164 | 39.894834 | 137 | py |
IBRNet | IBRNet-master/utils.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 5,709 | 30.202186 | 120 | py |
IBRNet | IBRNet-master/train.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 12,480 | 43.102473 | 112 | py |
IBRNet | IBRNet-master/eval/eval.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 12,287 | 51.289362 | 116 | py |
IBRNet | IBRNet-master/eval/render_llff_video.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 10,464 | 45.30531 | 114 | py |
IBRNet | IBRNet-master/ibrnet/feature_network.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 10,013 | 36.226766 | 122 | py |
IBRNet | IBRNet-master/ibrnet/render_ray.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 11,713 | 45.669323 | 128 | py |
IBRNet | IBRNet-master/ibrnet/model.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 6,829 | 38.94152 | 120 | py |
IBRNet | IBRNet-master/ibrnet/projection.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 6,442 | 46.029197 | 119 | py |
IBRNet | IBRNet-master/ibrnet/mlp_network.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 10,792 | 38.534799 | 125 | py |
IBRNet | IBRNet-master/ibrnet/criterion.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 1,019 | 28.142857 | 74 | py |
IBRNet | IBRNet-master/ibrnet/sample_ray.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 6,075 | 37.455696 | 120 | py |
IBRNet | IBRNet-master/ibrnet/render_image.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 4,189 | 37.796296 | 107 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/llff_test.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 6,679 | 42.376623 | 116 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/google_scanned_objects.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 5,089 | 40.382114 | 104 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/nerf_synthetic.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 6,607 | 39.048485 | 99 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/llff.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 6,403 | 43.472222 | 116 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/data_utils.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 9,650 | 35.695817 | 115 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/create_training_dataset.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 5,158 | 36.384058 | 119 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/ibrnet_collected.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 6,840 | 43.712418 | 116 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/deepvoxels.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 6,006 | 41.602837 | 107 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/spaces_dataset.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 18,846 | 38.845666 | 113 | py |
IBRNet | IBRNet-master/ibrnet/data_loaders/realestate.py | # Copyright 2020 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 5,939 | 38.078947 | 118 | py |
fish | fish-main/src/main.py | import copy
import argparse
import datetime
import json
import os
import sys
import csv
import tqdm
from collections import defaultdict
from tempfile import mkdtemp
import numpy as np
import torch
import torch.optim as optim
import models
from config import dataset_defaults
from utils import unpack_data, sample_domai... | 9,899 | 39.57377 | 117 | py |
fish | fish-main/src/utils.py | import os
import random
import shutil
import sys
import operator
from numbers import Number
from collections import OrderedDict
import torch
from torch import nn
from torch.utils.data import Dataset
# https://stackoverflow.com/questions/14906764/how-to-redirect-stdout-to-both-file-and-console-with-scripting
class Lo... | 5,047 | 27.845714 | 109 | py |
fish | fish-main/src/models/iwildcam.py | import os
from copy import deepcopy
import torch.nn as nn
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
from torchvision.models import resnet50
from wilds.common.data_loaders import get_eval_loader
from wilds.datasets.iwildcam_dataset import IWildCamDataset
from .datasets import ... | 2,488 | 37.292308 | 98 | py |
fish | fish-main/src/models/amazon.py | import os
from copy import deepcopy
import torch
from torch import nn
from torch.utils.data import DataLoader
from transformers import DistilBertForSequenceClassification
from transformers import DistilBertTokenizerFast
from transformers import logging
from wilds.common.data_loaders import get_eval_loader
from wilds.d... | 3,181 | 33.215054 | 98 | py |
fish | fish-main/src/models/fmow.py | import os
from copy import deepcopy
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
from torchvision.models import densenet121
from wilds.common.data_loaders import get_eval_loader
from wilds.datasets.fmow_dataset im... | 2,176 | 34.688525 | 98 | py |
fish | fish-main/src/models/poverty.py | import os
from copy import deepcopy
import torch.nn as nn
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
from wilds.common.data_loaders import get_eval_loader
from wilds.datasets.poverty_dataset import PovertyMapDataset
from .resnet_multispectral import ResNet18
from .datasets imp... | 2,596 | 34.094595 | 90 | py |
fish | fish-main/src/models/camelyon.py | import os
from copy import deepcopy
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
from torchvision.models import densenet121
from wilds.common.data_loaders import get_eval_loader
from wilds.datasets.camelyon17_data... | 2,514 | 37.106061 | 98 | py |
fish | fish-main/src/models/datasets.py | import copy
import os
import numpy as np
import torch
from PIL import Image
from torch.utils.data import Dataset
class Poverty_Batched_Dataset(Dataset):
"""
Batched dataset for Poverty. Allows for getting a batch of data given
a specific domain index.
"""
def __init__(self, dataset, split, batch_... | 17,458 | 39.792056 | 109 | py |
fish | fish-main/src/models/civil.py | import os
from copy import deepcopy
import torch
from torch import nn
from torch.utils.data import DataLoader
from transformers import DistilBertForSequenceClassification
from transformers import DistilBertTokenizerFast
from transformers import logging
from wilds.common.data_loaders import get_eval_loader
from wilds.d... | 3,199 | 34.164835 | 100 | py |
fish | fish-main/src/models/cdsprites.py | import os
from copy import deepcopy
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from .datasets import CDsprites_Dataset, DspritesDataset
# Constants
CDspritesDatasize = torch.Size([3, 64, 64])
CDspritesChans = CDspritesDatasize[0]
NUM_CLASSES = 2
class Model(nn.Module):
""" Classi... | 2,399 | 34.820896 | 95 | py |
fish | fish-main/src/models/resnet_multispectral.py | # Adapted from the WILDS library
import torch
import torch.nn as nn
def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=dilation, groups=groups, bias=False, dil... | 9,021 | 35.232932 | 106 | py |
ReachLipBnB-reachLipBnb | ReachLipBnB-reachLipBnb/packages.py | import numpy as np
import torch
from torch.autograd import Variable
from torch.autograd.grad_mode import no_grad
from torch.autograd.functional import jacobian
import torch.nn as nn
import matplotlib.pyplot as plt
from matplotlib import pyplot as plt, patches
import matplotlib.animation as animation
from matplotlib.l... | 381 | 19.105263 | 46 | py |
ReachLipBnB-reachLipBnb | ReachLipBnB-reachLipBnb/BranchAndBound.py | from packages import *
from Utilities.Plotter import Plotter
from BranchAndBoundNode import BB_node
from Bounding.LipschitzBound import LipschitzBounding
from Bounding.PgdUpperBound import PgdUpperBound
from Utilities.Timer import Timers
class BranchAndBound:
def __init__(self, coordUp=None, coordLow=None, verbos... | 13,630 | 50.052434 | 136 | py |
ReachLipBnB-reachLipBnb | ReachLipBnB-reachLipBnb/BranchAndBoundNode.py | import numpy as np
import torch
class BB_node:
def __init__(self, up=np.infty, low=-np.infty, coordUp: torch.Tensor=None, coordLow: torch.Tensor=None,
scoreFunction='length', depth=0, lipschitzConstant=None):
self.upper = up
self.lower = low
self.coordUpper = coord... | 1,860 | 36.22 | 108 | py |
ReachLipBnB-reachLipBnb | ReachLipBnB-reachLipBnb/run.py | from tabnanny import verbose
import torch
from packages import *
from BranchAndBound import BranchAndBound
from NeuralNetwork import NeuralNetwork
import pandas as pd
from sklearn.decomposition import PCA
import copy
import json
torch.set_printoptions(precision=8)
def calculateDirectionsOfOptimization(onlyPcaDirec... | 13,158 | 41.585761 | 130 | py |
ReachLipBnB-reachLipBnb | ReachLipBnB-reachLipBnb/NeuralNetwork.py | from packages import *
class NeuralNetwork(nn.Module):
def __init__(self, path, A=None, B=None, c=None):
super().__init__()
stateDictionary = torch.load(path, map_location=torch.device("cpu"))
layers = []
for keyEntry in stateDictionary:
if "weight" in keyEntry:
... | 1,366 | 31.547619 | 112 | py |
ReachLipBnB-reachLipBnb | ReachLipBnB-reachLipBnb/Bounding/PgdUpperBound.py | import torch
from torch.autograd import Variable
from torch.autograd.grad_mode import no_grad
from torch.autograd.functional import jacobian
class PgdUpperBound:
def __init__(self, network, numberOfInitializationPoints, numberOfPgdSteps, pgdStepSize,
inputSpaceDimension, device, maximumBatchSize)... | 3,948 | 43.370787 | 115 | py |
ReachLipBnB-reachLipBnb | ReachLipBnB-reachLipBnb/Bounding/LipschitzBound.py | from typing import List
import numpy as np
import torch
import torch.nn as nn
from copy import deepcopy
import cvxpy as cp
from scipy.linalg import block_diag
class LipschitzBounding:
def __init__(self,
network: nn.Module,
device=torch.device("cuda", 0),
virtua... | 22,315 | 52.260143 | 141 | py |
ReachLipBnB-reachLipBnb | ReachLipBnB-reachLipBnb/Config/ConfigGenerator.py | import json
import torch
import numpy as np
def main():
fileName = "unicycle"
eps = 0.01
verbose = 0
verboseMultiHorizon = 1
verboseEssential = 0
scoreFunction = 'worstLowerBound'
virtualBranching = False
numberOfVirtualBranches = 4
maxSearchDepthLipschitzBound = 10
normToUseLi... | 4,323 | 33.31746 | 90 | py |
DLow | DLow-master/motion_pred/exp_dlow.py | import os
import sys
import math
import pickle
import argparse
import time
from torch import optim
from torch.utils.tensorboard import SummaryWriter
sys.path.append(os.getcwd())
from utils import *
from motion_pred.utils.config import Config
from motion_pred.utils.dataset_h36m import DatasetH36M
from motion_pred.utils... | 5,313 | 34.426667 | 120 | py |
DLow | DLow-master/motion_pred/eval.py | import numpy as np
import argparse
import os
import sys
import pickle
import csv
from scipy.spatial.distance import pdist
sys.path.append(os.getcwd())
from utils import *
from motion_pred.utils.config import Config
from motion_pred.utils.dataset_h36m import DatasetH36M
from motion_pred.utils.dataset_humaneva import Da... | 8,260 | 31.269531 | 140 | py |
DLow | DLow-master/motion_pred/exp_vae.py | import os
import sys
import math
import pickle
import argparse
import time
from torch import optim
from torch.utils.tensorboard import SummaryWriter
sys.path.append(os.getcwd())
from utils import *
from motion_pred.utils.config import Config
from motion_pred.utils.dataset_h36m import DatasetH36M
from motion_pred.utils... | 4,219 | 36.017544 | 117 | py |
DLow | DLow-master/models/mlp.py | import torch.nn as nn
import torch
class MLP(nn.Module):
def __init__(self, input_dim, hidden_dims=(128, 128), activation='tanh'):
super().__init__()
if activation == 'tanh':
self.activation = torch.tanh
elif activation == 'relu':
self.activation = torch.relu
... | 759 | 28.230769 | 77 | py |
DLow | DLow-master/models/motion_pred.py | import torch
import numpy as np
from torch import nn
from torch.nn import functional as F
from models.mlp import MLP
from models.rnn import RNN
from utils.torch import *
class VAE(nn.Module):
def __init__(self, nx, ny, nz, horizon, specs):
super(VAE, self).__init__()
self.nx = nx
self.ny =... | 7,766 | 33.674107 | 118 | py |
DLow | DLow-master/models/rnn.py | import torch.nn as nn
from utils.torch import *
class RNN(nn.Module):
def __init__(self, input_dim, out_dim, cell_type='lstm', bi_dir=False):
super().__init__()
self.input_dim = input_dim
self.out_dim = out_dim
self.cell_type = cell_type
self.bi_dir = bi_dir
self.mo... | 2,440 | 34.376812 | 91 | py |
DLow | DLow-master/utils/torch.py | import torch
import numpy as np
from torch.optim import lr_scheduler
tensor = torch.tensor
DoubleTensor = torch.DoubleTensor
FloatTensor = torch.FloatTensor
LongTensor = torch.LongTensor
ByteTensor = torch.ByteTensor
ones = torch.ones
zeros = torch.zeros
class to_cpu:
def __init__(self, *models):
self.m... | 4,921 | 26.80791 | 116 | py |
DLow | DLow-master/utils/__init__.py | from utils.torch import *
from utils.logger import *
| 53 | 17 | 26 | py |
MARL | MARL-master/S2SRL/data_test_maml_retriever.py | # !/usr/bin/env python3
# The file is used to predict the action sequences for full-data test dataset.
import argparse
import logging
import sys
from libbots import data, model, utils, metalearner, retriever_module
import torch
log = logging.getLogger("data_test")
DIC_PATH = '../data/auto_QA_data/share.question'
TRA... | 10,204 | 61.607362 | 264 | py |
MARL | MARL-master/S2SRL/train_maml_retriever_joint.py | #!/usr/bin/env python3
import os
import sys
import random
import argparse
import logging
import numpy as np
from tensorboardX import SummaryWriter
from libbots import data, model, utils, metalearner, retriever_module
import torch
import torch.optim as optim
import time
import ptan
SAVES_DIR = "../data/saves"
MAX_EP... | 19,707 | 62.574194 | 463 | py |
MARL | MARL-master/S2SRL/retriever_pretrain.py | import os
import json
import torch
import random
from datetime import datetime
from statistics import mean
from libbots import adabound, data, model, metalearner, retriever_module
MAX_TOKENS = 40
MAX_MAP = 1000000
DIC_PATH = '../data/auto_QA_data/share.question'
SAVES_DIR = '../data/saves/retriever'
QID_RANGE = '../da... | 17,262 | 51.471125 | 158 | py |
MARL | MARL-master/S2SRL/libbots/adabound.py | import math
import torch
from torch.optim import Optimizer
class AdaBound(Optimizer):
"""Implements AdaBound algorithm.
It has been proposed in `Adaptive Gradient Methods with Dynamic Bound of Learning Rate`_.
Arguments:
params (iterable): iterable of parameters to optimize or dicts defining
... | 11,340 | 47.465812 | 101 | py |
MARL | MARL-master/S2SRL/libbots/reparam_module.py | import torch
import torch.nn as nn
import warnings
import types
from collections import namedtuple
from contextlib import contextmanager
# A module is a container from which layers, model subparts (e.g. BasicBlock in resnet in torchvision) and models should inherit.
# Why should they? Because the inheritance from nn.M... | 12,361 | 53.219298 | 152 | py |
MARL | MARL-master/S2SRL/libbots/retriever_module.py | import torch.nn as nn
import torch
import torch.nn.functional as F
class RetrieverModel(nn.Module):
def __init__(self, emb_size, dict_size, EMBED_FLAG=False, hid1_size=300, hid2_size=200, output_size=128, device='cpu'):
# Call __init__ function of PhraseModel's parent class (nn.Module).
super(Retri... | 3,495 | 43.820513 | 123 | py |
MARL | MARL-master/S2SRL/libbots/model.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.utils.rnn as rnn_utils
import torch.nn.functional as F
from collections import OrderedDict
from . import utils
from . import attention
HIDDEN_STATE_SIZE = 128
EMBEDDING_DIM = 50
# nn.Module: Base class for all neural network modules.
# Your mode... | 15,803 | 46.746224 | 177 | py |
MARL | MARL-master/S2SRL/libbots/data.py | import collections
import os
import sys
import logging
import itertools
import pickle
import json
import torch
from . import cornell
UNKNOWN_TOKEN = '#UNK'
BEGIN_TOKEN = "#BEG"
END_TOKEN = "#END"
MAX_TOKENS = 30
MIN_TOKEN_FEQ = 1
SHUFFLE_SEED = 1987
LINE_SIZE = 50000
EMB_DICT_NAME = "emb_dict.dat"
EMB_NAME = "emb.np... | 17,887 | 35.431772 | 233 | py |
MARL | MARL-master/S2SRL/libbots/metalearner.py | import torch
from torch.nn.utils.convert_parameters import (vector_to_parameters,
parameters_to_vector)
from . import data, model, utils, retriever, reparam_module, adabound
import torch.optim as optim
import torch.nn.functional as F
import random
import logging
from torch... | 86,631 | 58.377656 | 330 | py |
MARL | MARL-master/S2SRL/libbots/attention.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.utils.rnn as rnn_utils
class Attention(nn.Module):
r"""
Applies an attention mechanism on the output features from the decoder.
.. math::
\begin{array}{ll}
x = context*output \\
attn = ex... | 3,752 | 44.768293 | 191 | py |
MARL | MARL-master/S2SRL/libbots/metalearner_webqsp.py | import torch
from torch.nn.utils.convert_parameters import (vector_to_parameters,
parameters_to_vector)
from . import data, model, utils, retriever_webqsp, reparam_module, adabound
import torch.optim as optim
import torch.nn.functional as F
import random
import logging
imp... | 67,427 | 58.043783 | 290 | py |
climin | climin-master/docs/source/conf.py | # -*- coding: utf-8 -*-
#
# climin documentation build configuration file, created by
# sphinx-quickstart on Tue May 7 13:56:19 2013.
#
# 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.
#
# All ... | 8,175 | 31.444444 | 185 | py |
Tensor_Radiomics | Tensor_Radiomics-main/Bin_size_Flavour/tr_net.py |
import os
import numpy as np
import tensorflow as tf
import keras
from keras.utils import normalize
from keras.utils import to_categorical
from keras.models import Model
from keras.layers import Input, MaxPooling2D, concatenate, BatchNormalization, Dropout, Lambda, Dense
from keras.models import load_model
from keras... | 11,475 | 30.016216 | 138 | py |
Tensor_Radiomics | Tensor_Radiomics-main/SegmentationFlavors/SegFlavors_LDAPrediction.py | import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
import SimpleITK as sitk
from scipy import stats
import radiomics
from radiomics import featureextractor
import logging
import matplotlib.pyplot as plt
import numpy as np
import os, time
import pandas as pd
import torchio as tio
import torch... | 30,210 | 39.825676 | 173 | py |
corelay | corelay-master/src/corelay/io/hashing.py | """Persistent, non-cryptographic hashing of python objects.
Note
----
See https://github.com/chr5tphr/funcache/blob/master/funcache/hashing.py
"""
import pickle
import numpy as np
from numpy import ndarray
# pylint: disable=no-name-in-module
from metrohash import MetroHash128
try:
from torch import Tensor
except... | 1,452 | 24.491228 | 72 | py |
corelay | corelay-master/docs/source/conf.py | import sys
import os
from subprocess import run, CalledProcessError
import inspect
import pkg_resources
from pybtex.style.formatting.plain import Style as PlainStyle
from pybtex.style.labels import BaseLabelStyle
from pybtex.plugin import register_plugin
# -- Project information -------------------------------------... | 3,699 | 24.694444 | 96 | py |
RobustForensics | RobustForensics-master/save_aligned_faces.py | import os
import sys
import cv2
import torch
import copy
import pickle
def mkdir(path):
try:
os.makedirs(path)
except:
pass
def get_boundingbox(face, width, height, scale=1.3, minsize=None):
"""
Expects a dlib face to generate a quadratic bounding box.
:param face: dlib face clas... | 10,876 | 34.662295 | 115 | py |
RobustForensics | RobustForensics-master/image_based/main.py | import multiprocessing as mp
mp.set_start_method('spawn', force=True)
import argparse
import os
import time
import yaml
import pickle
import numpy
import logging
from easydict import EasyDict
from datetime import datetime
import pprint
from tensorboardX import SummaryWriter
import torch
import torch.nn as nn
import tor... | 20,277 | 39.556 | 213 | py |
RobustForensics | RobustForensics-master/image_based/optim.py | from torch.optim import SGD
from torch.optim import Adam
from torch.optim.optimizer import Optimizer, required
def optim_entry(config):
return globals()[config['type']](**config['kwargs'])
| 194 | 26.857143 | 56 | py |
RobustForensics | RobustForensics-master/image_based/utils.py | import os
import logging
import shutil
import torch
from datetime import datetime
from torch.utils.data.sampler import Sampler
import torch.distributed as dist
import math
import numpy as np
import torch
def create_logger(name, log_file, level=logging.INFO):
l = logging.getLogger(name)
formatter = logging.Form... | 9,150 | 32.767528 | 112 | py |
RobustForensics | RobustForensics-master/image_based/dataset.py | from torch.utils.data import DataLoader, Dataset
import numpy as np
import os
import cv2
import bisect
import random
import torch.distributed as dist
def cv2_loader(img_str):
return cv2.imread(img_str, cv2.IMREAD_COLOR)
class FaceDataset(Dataset):
def __init__(self, root_dir, source, transform=None,
... | 3,515 | 34.515152 | 94 | py |
RobustForensics | RobustForensics-master/image_based/scheduler.py | import torch
from easydict import EasyDict
from bisect import bisect_right
def get_scheduler(config):
config = EasyDict(config)
if config.type == 'STEP':
return StepLRScheduler(config.optimizer, config.lr_steps, config.lr_mults, config.base_lr, config.warmup_lr, config.warmup_steps, last_iter=config.l... | 3,557 | 40.858824 | 165 | py |
RobustForensics | RobustForensics-master/image_based/distributed_utils.py | import os
import torch
import torch.distributed as dist
def dist_init(file_path):
proc_id = int(os.environ['SLURM_PROCID'])
ntasks = int(os.environ['SLURM_NTASKS'])
node_list = os.environ['SLURM_NODELIST']
num_gpus = torch.cuda.device_count()
torch.cuda.set_device(proc_id%num_gpus)
method = "fi... | 568 | 32.470588 | 60 | py |
RobustForensics | RobustForensics-master/image_based/models/resnet.py | import torch
import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
import torch.distributed as dist
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet50c', 'resnet50d', 'resnet101',
'resnet152']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet1... | 9,910 | 31.709571 | 97 | py |
RobustForensics | RobustForensics-master/image_based/models/models.py | import os
import torch.distributed as dist
import torch
import torch.nn as nn
from .xception import xception
from utils import print_with_rank
def pretrain(model, state_dict):
own_state = model.state_dict()
for name, param in state_dict.items():
if name in own_state:
if isinstance(param, ... | 3,027 | 36.85 | 91 | py |
RobustForensics | RobustForensics-master/image_based/models/__init__.py | from .models import model_selection
from .efficientnet_pytorch.model import *
from .resnet import *
def model_entry(config):
if config['arch'] == 'xception':
model = model_selection(
modelname='xception',
num_out_classes=config['kwargs']['num_classes'],
pretrain_path=con... | 617 | 33.333333 | 80 | py |
RobustForensics | RobustForensics-master/image_based/models/xception.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
from torch.nn import init
__all__ = ['xception']
class SeparableConv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=1, stride=1, padding=0, dilation=1, bias=False):
... | 5,863 | 30.869565 | 116 | py |
RobustForensics | RobustForensics-master/image_based/models/efficientnet_pytorch/utils.py | """
This file contains helper functions for building the model and for loading model parameters.
These helper functions are built to mirror those in the official TensorFlow implementation.
"""
import re
import math
import collections
from functools import partial
import torch
from torch import nn
from torch.nn import ... | 12,702 | 38.450311 | 112 | py |
RobustForensics | RobustForensics-master/image_based/models/efficientnet_pytorch/model.py | import torch
from torch import nn
from torch.nn import functional as F
from .utils import (
round_filters,
round_repeats,
drop_connect,
get_same_padding_conv2d,
get_model_params,
efficientnet_params,
load_pretrained_weights,
Swish,
MemoryEfficientSwish,
)
class MBConvBlock(nn.Modu... | 9,672 | 40.874459 | 114 | py |
RobustForensics | RobustForensics-master/video_based/main.py | import multiprocessing as mp
mp.set_start_method('spawn', force=True)
import argparse
import os
import time
import yaml
import pickle
import numpy
import logging
from easydict import EasyDict
from datetime import datetime
import torch.distributed as dist
import pprint
from tensorboardX import SummaryWriter
import torc... | 21,586 | 39.349533 | 157 | py |
RobustForensics | RobustForensics-master/video_based/optim.py | from torch.optim import SGD
from torch.optim import Adam
def optim_entry(config):
return globals()[config['type']](**config['kwargs'])
| 149 | 20.428571 | 56 | py |
RobustForensics | RobustForensics-master/video_based/utils.py | import os
import logging
import shutil
import torch
from datetime import datetime
from torch.utils.data.sampler import Sampler
import torch.distributed as dist
import math
import numpy as np
import torch
def create_logger(name, log_file, level=logging.INFO):
l = logging.getLogger(name)
formatter = logging.Form... | 9,150 | 32.767528 | 112 | py |
RobustForensics | RobustForensics-master/video_based/dataset.py | from torch.utils.data import DataLoader, Dataset
import numpy as np
import os
from PIL import Image
import bisect
import random
import torch
import torch.distributed as dist
def pil_loader(img_str):
with open(img_str, 'rb') as f:
with Image.open(f) as img:
img = img.convert('RGB')
return i... | 3,134 | 32.709677 | 113 | py |
RobustForensics | RobustForensics-master/video_based/scheduler.py | import torch
from easydict import EasyDict
from bisect import bisect_right
def get_scheduler(config):
config = EasyDict(config)
if config.type == 'STEP':
return StepLRScheduler(config.optimizer, config.lr_steps, config.lr_mults, config.base_lr, config.warmup_lr, config.warmup_steps, last_iter=config.l... | 3,557 | 40.858824 | 165 | py |
RobustForensics | RobustForensics-master/video_based/distributed_utils.py | import os
import torch
import torch.distributed as dist
def dist_init(file_path):
proc_id = int(os.environ['SLURM_PROCID'])
ntasks = int(os.environ['SLURM_NTASKS'])
node_list = os.environ['SLURM_NODELIST']
num_gpus = torch.cuda.device_count()
torch.cuda.set_device(proc_id%num_gpus)
method = "fi... | 568 | 32.470588 | 60 | py |
RobustForensics | RobustForensics-master/video_based/spatial_transforms.py | import random
import collections
import numpy as np
import torch
from PIL import Image, ImageOps
try:
import accimage
except ImportError:
accimage = None
import cv2
import albumentations.augmentations.functional as F
class Compose(object):
"""Composes several transforms together.
Args:
transfo... | 11,785 | 31.738889 | 116 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.