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 |
|---|---|---|---|---|---|---|
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/kernels.py | import gpytorch
import torch
import torch.nn as nn
class NNKernel(nn.Module):
def __init__(self, input_dim: int, output_dim: int, num_layers: int, hidden_dim: int, flatten: bool =False, **kwargs):
super().__init__()
self.input_dim = input_dim
self.output_dim = output_dim
self.num_l... | 11,422 | 37.591216 | 122 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/maml.py | # This code is modified from https://github.com/dragen1860/MAML-Pytorch and https://github.com/katerakelly/pytorch-maml
import torch
import backbone
import numpy as np
import torch.nn as nn
from torch.autograd import Variable
from methods.meta_template import MetaTemplate
from time import time
class MAML(MetaTempla... | 6,570 | 39.312883 | 176 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/meta_template.py | from collections import defaultdict
from typing import Tuple
import backbone
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
import torch.nn.functional as F
import utils
from abc import abstractmethod
class MetaTemplate(nn.Module):
def __init__(self, model_func, n_way, n_... | 5,764 | 36.679739 | 140 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/DKT.py | ## Original packages
import backbone
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
import torch.nn.functional as F
from methods.meta_template import MetaTemplate
## Our packages
import gpytorch
from time import gmtime, strftime
import random
from configs import kernel_type
f... | 20,017 | 50.328205 | 251 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/protonet.py | # This code is modified from https://github.com/jakesnell/prototypical-networks
import backbone
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
import torch.nn.functional as F
from methods.meta_template import MetaTemplate
class ProtoNet(MetaTemplate):
def __init__(self,... | 1,434 | 27.7 | 112 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/baselinetrain.py | import backbone
import utils
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
import torch.nn.functional as F
class BaselineTrain(nn.Module):
def __init__(self, model_func, num_class, loss_type = 'softmax'):
super(BaselineTrain, self).__init__()
self.featur... | 1,780 | 32.603774 | 124 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/baselinefinetune.py | import backbone
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
import torch.nn.functional as F
from methods.meta_template import MetaTemplate
class BaselineFinetune(MetaTemplate):
def __init__(self, model_func, n_way, n_support, loss_type = "softmax"):
super(Base... | 2,381 | 39.372881 | 124 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/kernel_convolutions.py | import torch
import torch.nn as nn
class KernelConv(nn.Module):
def __init__(self, n_shot, hn_kernel_convolution_output_dim):
super(KernelConv, self).__init__()
if n_shot == 5:
self.conv = nn.Sequential(
nn.Conv2d(1, 2, kernel_size=(5, 5)),
nn.ReLU(inpla... | 1,174 | 34.606061 | 78 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/transformer.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
def scaled_dot_product(q, k, v, mask=None):
d_k = q.size()[-1]
attn_logits = torch.matmul(q, k.transpose(-2, -1))
attn_logits = attn_logits / math.sqrt(d_k)
if mask is not None:
attn_logits = attn_logits.masked_fill... | 4,046 | 32.172131 | 98 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/feature_transfer_regression.py | import numpy as np
import gpytorch
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import backbone
from torch.autograd import Variable
from data.qmul_loader import get_batch, train_people, test_people
class Regressor(nn.Module):
def __init__(self):
super(Regre... | 3,110 | 33.955056 | 123 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/DKT_regression.py | ## Original packages
import backbone
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
import math
import torch.nn.functional as F
## Our packages
import gpytorch
from time import gmtime, strftime
import random
from statistics import mean
from data.qmul_loader import get_batch, ... | 4,900 | 36.7 | 130 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/matchingnet.py | # This code is modified from https://github.com/facebookresearch/low-shot-shrink-hallucinate
import backbone
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
import torch.nn.functional as F
from methods.meta_template import MetaTemplate
import utils
import copy
class MatchingN... | 3,749 | 35.764706 | 199 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/hypernets/hypernet_kernel.py | from copy import deepcopy
from typing import Optional, Tuple
import torch
from torch import nn
from methods.hypernets import HyperNetPOC
from methods.hypernets.utils import set_from_param_dict, accuracy_from_scores
from methods.kernel_convolutions import KernelConv
from methods.kernels import init_kernel_function
fro... | 13,719 | 43.983607 | 131 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/hypernets/hypermaml.py | from collections import defaultdict
from copy import deepcopy
from time import time
import numpy as np
import torch
from torch import nn as nn
from torch.autograd import Variable
from torch.nn import functional as F
import backbone
from methods.hypernets.utils import get_param_dict, accuracy_from_scores
from methods.... | 23,248 | 39.503484 | 147 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/hypernets/utils.py | from typing import Dict
import numpy as np
import torch
from torch import nn
def get_param_dict(net: nn.Module) -> Dict[str, nn.Parameter]:
"""A dict of named parameters of an nn.Module"""
return {
n: p
for (n, p) in net.named_parameters()
}
def set_from_param_dict(module: nn.Module, pa... | 2,398 | 31.418919 | 110 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/hypernets/hypernet_poc.py | from collections import defaultdict
from copy import deepcopy
from typing import Dict, Optional
import numpy as np
import torch
from torch import nn
from torch.utils.data import DataLoader
from methods.hypernets.utils import get_param_dict, set_from_param_dict, SinActivation, accuracy_from_scores
from methods.meta_te... | 18,022 | 41.607565 | 180 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/methods/hypernets/bayeshmaml.py | from copy import deepcopy
import numpy as np
import torch
from torch import nn as nn
from torch.autograd import Variable
from torch.nn import functional as F
import backbone
from methods.hypernets.utils import get_param_dict, kl_diag_gauss_with_standard_gauss, \
reparameterize
from methods.hypernets.hypermaml impo... | 20,114 | 41.08159 | 147 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/models/gp_kernels.py | import gpytorch
import torch
import torch.nn as nn
import numpy as np
class NNKernel(gpytorch.kernels.Kernel):
def __init__(self, input_dim, output_dim, num_layers, hidden_dim, flatten=False, **kwargs):
super(NNKernel, self).__init__(**kwargs)
self.input_dim = input_dim
self.output_dim = ... | 8,368 | 39.429952 | 118 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/data/additional_transforms.py | # Copyright 2017-present, Facebook, Inc.
# 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 torch
from PIL import ImageEnhance
transformtypedict=dict(Brightness=ImageEnhance.Brightness, Contrast=ImageEnhance.Contrast... | 850 | 24.787879 | 150 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/data/feature_loader.py | import torch
import numpy as np
import h5py
class SimpleHDF5Dataset:
def __init__(self, file_handle = None):
if file_handle == None:
self.f = ''
self.all_feats_dset = []
self.all_labels = []
self.total = 0
else:
self.f = file_handle
... | 1,293 | 27.755556 | 78 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/data/dataset.py | # This code is modified from https://github.com/facebookresearch/low-shot-shrink-hallucinate
import torch
from PIL import Image
import json
import numpy as np
import torchvision.transforms as transforms
import os
identity = lambda x:x
class SimpleDataset:
def __init__(self, data_file, transform, target_transform=i... | 2,913 | 31.741573 | 108 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/data/datamgr.py | # This code is modified from https://github.com/facebookresearch/low-shot-shrink-hallucinate
import torch
from PIL import Image
import numpy as np
import torchvision.transforms as transforms
import data.additional_transforms as add_transforms
from data.dataset import SimpleDataset, SetDataset, EpisodicBatchSampler
fro... | 3,560 | 38.566667 | 118 | py |
few-shot-hypernets-public | few-shot-hypernets-public-master/data/qmul_loader.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.autograd import Variable
import torchvision.transforms as transforms
from PIL import Image
train_people = ['DennisPNoGlassesGrey','JohnGrey','SimonBGrey','SeanGGrey','DanJGrey','AdamBGrey','JackGrey','RichardHGrey','Yongmi... | 2,209 | 35.833333 | 347 | py |
AICare | AICare-main/AICare.py | class Sparsemax(nn.Module):
"""Sparsemax function."""
def __init__(self, dim=None):
super(Sparsemax, self).__init__()
self.dim = -1 if dim is None else dim
def forward(self, input, device='cuda'):
original_size = input.size()
input = input.view(-1, input.size(self.dim))
... | 19,067 | 42.042889 | 195 | py |
GANFingerprints | GANFingerprints-master/classifier/nets/resnet_utils.py | # Copyright 2016 The TensorFlow Authors. 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 applicable ... | 11,901 | 42.123188 | 80 | py |
GANFingerprints | GANFingerprints-master/classifier_visNet/nets/resnet_utils.py | # Copyright 2016 The TensorFlow Authors. 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 applicable ... | 11,901 | 42.123188 | 80 | py |
SpectralANN | SpectralANN-main/MonteCarloTest.py | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 20 11:22:43 2021
@author: Thibault
"""
import torch
from ACANN import ACANN
from torch.utils.data import DataLoader
import numpy as np
import matplotlib.pyplot as plt
import inputParameters as config
import pandas as pd
from matplotlib.legend_handler import HandlerTuple
f... | 11,372 | 29.328 | 120 | py |
SpectralANN | SpectralANN-main/train_ACANN.py | from ACANN import ACANN
from Database import Database
from torch.nn.modules.loss import KLDivLoss,L1Loss,MSELoss
from torch.optim import Adam,Rprop,Adamax, RMSprop,SGD,LBFGS,AdamW
from torch.utils.data import DataLoader
import torch
import inputParameters as config
import matplotlib.pyplot as plt
import os
os.environ[... | 4,320 | 35.008333 | 146 | py |
SpectralANN | SpectralANN-main/robustnessCheck.py | # -*- coding: utf-8 -*-
"""
Created on Thu Sep 2 17:54:33 2021
@author: Thibault
"""
#1: add noise 20 times to same propagator
#2: Convert to correct input
#3: Input to NN
#4: Calc average and stddev of spectral functions
indices = [227, 1552, 112, 1243, 606]
nbrOfSamples = 100
noiseSize = 1e-2
from Database i... | 12,731 | 33.597826 | 144 | py |
SpectralANN | SpectralANN-main/Database.py | from torch.utils.data import TensorDataset
import pandas as pd
import torch
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
print("Using",device)
class Database():
def __init__(self, csv_target, csv_input, transform=None,nb_data=25000):
"""
Build the data set structure
... | 1,130 | 38 | 79 | py |
SpectralANN | SpectralANN-main/test_ACANN.py | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 27 10:53:43 2021
@author: Thibault
"""
import torch
from ACANN import ACANN
from Database import Database
from torch.utils.data import DataLoader
import numpy as np
import matplotlib.pyplot as plt
import inputParameters as config
import pandas as pd
from matplotlib.legend... | 12,953 | 32.734375 | 120 | py |
SpectralANN | SpectralANN-main/propagatorNoise.py | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 30 15:06:14 2021
@author: Thibault
"""
from Database import Database
from torch.utils.data import DataLoader
import inputParameters as config
import numpy as np
import pandas as pd
import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
noiseSize = 5e-3
#Load input parame... | 2,951 | 27.660194 | 101 | py |
SpectralANN | SpectralANN-main/ACANN.py | import torch.nn as nn
import torch.nn.functional as F
import torch
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
class ACANN(nn.Module):
def __init__(self,input_size,output_size,hidden_layers,drop_p=0.05):
""" Builds ACANN network with arbitrary number of hidden layers.
... | 1,617 | 29.528302 | 95 | py |
NeuralBKI | NeuralBKI-main/generate_results.py | # This file generates results for evaluation by loading semantic predictions from files.
# Not intended for use on-board robot.
import os
import pdb
import time
import json
import rospy
import yaml
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
import numpy as np
import copy
from tqdm import tqdm
# Torch imports
import to... | 13,528 | 41.410658 | 150 | py |
NeuralBKI | NeuralBKI-main/train.py | import os
import pdb
import time
import json
import yaml
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
import numpy as np
from tqdm import tqdm
# Torch imports
import torch
from torch import nn
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader
from torch.utils.tensorboard import SummaryWriter
#... | 11,927 | 39.989691 | 141 | py |
NeuralBKI | NeuralBKI-main/Data/KittiOdometry.py | import os
import numpy as np
# from utils import laserscan
import yaml
from torch.utils.data import Dataset
import torch
# import spconv
import math
from scipy.spatial.transform import Rotation as R
config_file = os.path.join('Config/kitti_odometry.yaml')
kitti_config = yaml.safe_load(open(config_file, 'r'))
SPLIT_SEQ... | 14,054 | 40.217009 | 123 | py |
NeuralBKI | NeuralBKI-main/Data/utils.py | import os
import pdb
from matplotlib import markers
import rospy
import numpy as np
import time
import os
import pdb
import torch
from visualization_msgs.msg import *
from geometry_msgs.msg import Point32
from std_msgs.msg import ColorRGBA
# Intersection, union for one frame
def iou_one_frame(pred, target, n_classes=2... | 4,931 | 31.662252 | 109 | py |
NeuralBKI | NeuralBKI-main/Data/SemanticKitti.py | import os
import numpy as np
# from utils import laserscan
import yaml
from torch.utils.data import Dataset
import torch
# import spconv
import math
from scipy.spatial.transform import Rotation as R
config_file = os.path.join('Config/semantic_kitti.yaml')
kitti_config = yaml.safe_load(open(config_file, 'r'))
remapdict... | 15,165 | 39.878706 | 134 | py |
NeuralBKI | NeuralBKI-main/Data/Rellis3D.py | ## Maintainer: Arthur Zhang #####
## Contact: arthurzh@umich.edu #####
import os
import pdb
import math
import numpy as np
import random
import json
import yaml
from sklearn.metrics import homogeneity_completeness_v_measure
import torch
from torch import gt
import torch.nn.functional as F
from torch.utils.data import... | 11,319 | 38.719298 | 154 | py |
NeuralBKI | NeuralBKI-main/Models/model_utils.py | import pdb
import torch
import random
import numpy as np
from torch import empty
from torch import long
from Models.ConvBKI import ConvBKI
def setup_seed(seed=42):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
def measure_inf_time(model, inputs, rep... | 1,843 | 30.254237 | 111 | py |
NeuralBKI | NeuralBKI-main/Models/ConvBKI.py | import pdb
import os
import torch
torch.backends.cudnn.deterministic = True
import torch.nn.functional as F
class ConvBKI(torch.nn.Module):
def __init__(self, grid_size, min_bound, max_bound, filter_size=3,
num_classes=21, prior=0.001, device="cpu", datatype=torch.float32,
max_di... | 9,899 | 47.292683 | 123 | py |
NeuralBKI | NeuralBKI-main/Models/mapping_utils.py | # This file contains classes for local and global offline mapping (not running semantic prediction)
import torch
import torch.nn.functional as F
import numpy as np
import time
from Models.ConvBKI import ConvBKI
# TODO: Trilinear interpolation
# Save grid in CPU memory, load to GPU when needed for update step
# Voxels... | 7,482 | 46.66242 | 142 | py |
NeuralBKI | NeuralBKI-main/Models/BKINet.py | import torch
# BKINet consists of two components:
# 1) A pre-trained semantic segmentation model
# 2) A pre-trained ConvBKI layer
# This module is intended for ROS integration
class BKINet(torch.nn.Module):
def __init__(self, grid_size, min_bound, max_bound, weights, filter_size, segmentation_net,
... | 1,442 | 34.195122 | 106 | py |
pivnet | pivnet-main/pivnet.py | from typing import List
import pickle, itertools
from numba import jit, i4, i8, f4, typeof
from numba.typed import List
from numba.experimental import jitclass
import numpy as np
from sklearn.preprocessing import StandardScaler
from collections import OrderedDict
from scipy.spatial import KDTree
import multiprocessing ... | 10,860 | 30.120344 | 73 | py |
tdqn | tdqn-master/tdqn/tdqn.py | import time
import math, random
import numpy as np
from os.path import join as pjoin
import torch
import torch.nn as nn
import torch.optim as optim
import torch.autograd as autograd
import torch.nn.functional as F
import logger
import copy
from replay import *
from schedule import *
from models import TDQN
from env... | 11,644 | 37.816667 | 119 | py |
tdqn | tdqn-master/tdqn/models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import random
class TDQN(nn.Module):
def __init__(self, args, template_size, vocab_size, vocab_size_act):
super(TDQN, self).__init__()
self.embeddings = nn.Embedding(vocab_siz... | 5,149 | 40.532258 | 98 | py |
tdqn | tdqn-master/drrn/drrn.py | import pickle
import torch
import torch.nn as nn
import torch.nn.functional as F
from os.path import join as pjoin
from memory import ReplayMemory, Transition, State
from model import DRRN
from util import *
import logger
import sentencepiece as spm
device = torch.device("cuda" if torch.cuda.is_available() else "cpu"... | 3,809 | 36.722772 | 104 | py |
tdqn | tdqn-master/drrn/model.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import random
import itertools
from util import pad_sequences
from memory import State
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
class DRRN(torch.nn.Module):
"""
Deep Reinforcement Relevance... | 4,282 | 40.990196 | 96 | py |
tdqn | tdqn-master/drrn/train.py | import subprocess
import time
import os
import torch
import logger
import argparse
import yaml
import jericho
from os.path import basename, dirname
from drrn import DRRN_Agent
from vec_env import VecEnv
from env import JerichoEnv
from jericho.util import clean
def configure_logger(log_dir):
logger.configure(log_d... | 5,988 | 38.926667 | 118 | py |
RioGNN | RioGNN-main/train.py | import os
import argparse
from time import localtime, strftime, time
from sklearn.model_selection import train_test_split
from utils.utils import *
from model.model import *
from model.layers import *
from model.graphsage import *
from RL.rl_model import *
"""
Training and testing RIO-GNN
Paper: Reinforced Nei... | 8,973 | 45.497409 | 120 | py |
RioGNN | RioGNN-main/RL/actor_critic.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
"""
Actor-Critic implementations
Paper: Actor-Critic Algorithms
Source: https://github.com/llSourcell/actor_critic
"""
# torch.backends.cudnn.enabled = False # Non-deterministic algorithm
class PGNetwork(nn.Module):
... | 4,388 | 32.761538 | 105 | py |
RioGNN | RioGNN-main/model/graphsage.py | import torch
import torch.nn as nn
from torch.nn import init
import torch.nn.functional as F
from torch.autograd import Variable
import random
"""
GraphSAGE implementations
Paper: Inductive Representation Learning on Large Graphs
Source: https://github.com/williamleif/graphsage-simple/
"""
class GraphSage(nn.Mod... | 4,341 | 27.946667 | 101 | py |
RioGNN | RioGNN-main/model/model.py | import torch
import torch.nn as nn
from torch.nn import init
from torch.autograd import Variable
"""
Rio-GNN Models
Paper: Reinforced Neighborhood Selection Guided Multi-Relational Graph Neural Networks
Source: https://github.com/safe-graph/RioGNN
"""
class OneLayerRio(nn.Module):
"""
The Rio-GNN model in one l... | 3,611 | 34.067961 | 91 | py |
RioGNN | RioGNN-main/model/layers.py | import sys
import torch
import torch.nn as nn
from torch.nn import init
import torch.nn.functional as F
from torch.autograd import Variable
from operator import itemgetter
import math
from RL.rl_model import *
"""
Rio-GNN Layers
Paper: Reinforced Neighborhood Selection Guided Multi-Relational Graph Neural Netw... | 18,857 | 42.855814 | 119 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_copy_detection.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 12,631 | 40.827815 | 160 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_linear.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 13,256 | 46.010638 | 135 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_image_retrieval.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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,288 | 44.985149 | 192 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/hubconf.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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,653 | 36.197368 | 124 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/visualize_attention.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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,389 | 42.878505 | 157 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 28,039 | 32.783133 | 119 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/video_generation.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 13,669 | 35.068602 | 135 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/vision_transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 12,706 | 37.389728 | 124 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/main_dino4k.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 23,147 | 47.225 | 136 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_knn.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 11,128 | 44.798354 | 117 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/vision_transformer4k.py | import argparse
import os
import sys
import datetime
import time
import math
import json
from pathlib import Path
import numpy as np
from PIL import Image
import torch
import torch.nn as nn
import torch.distributed as dist
import torch.backends.cudnn as cudnn
import torch.nn.functional as F
from torchvision import dat... | 10,220 | 35.503571 | 123 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/main_dino.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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,945 | 47.614407 | 114 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_video_segmentation.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 11,835 | 39.395904 | 153 | py |
HIPT | HIPT-master/3-Self-Supervised-Eval/patch_extraction.py | ### Dependencies
# Base Dependencies
import os
import pickle
import sys
# LinAlg / Stats / Plotting Dependencies
import h5py
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from PIL import Image
import umap
import umap.plot
from tqdm import tqdm
# Torch Dependencies
import torch
import torch.mu... | 1,521 | 34.395349 | 125 | py |
HIPT | HIPT-master/3-Self-Supervised-Eval/slide_extraction_utils.py | # Base Dependencies
import os
import pickle
import sys
j_ = os.path.join
# LinAlg / Stats / Plotting Dependencies
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from PIL import Image
from tqdm import tqdm
# Scikit-Learn Imports
import sklearn
from sklearn.linear_model import LogisticRegressio... | 6,006 | 37.754839 | 118 | py |
HIPT | HIPT-master/3-Self-Supervised-Eval/patch_extraction_utils.py | ### Dependencies
# Base Dependencies
import os
import pickle
import sys
# LinAlg / Stats / Plotting Dependencies
import h5py
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from PIL import Image
import umap
import umap.plot
from tqdm import tqdm
# Torch Dependencies
import torch
import torch.mu... | 11,702 | 46.573171 | 117 | py |
HIPT | HIPT-master/HIPT_4K/hipt_4k.py | ### Dependencies
# Base Dependencies
import os
import pickle
import sys
# LinAlg / Stats / Plotting Dependencies
import h5py
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from PIL import Image
Image.MAX_IMAGE_PIXELS = None
from tqdm import tqdm
# Torch Dependencies
import torch
import torch.m... | 15,783 | 46.830303 | 149 | py |
HIPT | HIPT-master/HIPT_4K/hipt_heatmap_utils.py | ### Dependencies
# Base Dependencies
import argparse
import colorsys
from io import BytesIO
import os
import random
import requests
import sys
# LinAlg / Stats / Plotting Dependencies
import cv2
import h5py
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import numpy as np
from... | 31,892 | 46.672646 | 163 | py |
HIPT | HIPT-master/HIPT_4K/vision_transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 12,706 | 37.389728 | 124 | py |
HIPT | HIPT-master/HIPT_4K/vision_transformer4k.py | import argparse
import os
import sys
import datetime
import time
import math
import json
from pathlib import Path
import numpy as np
from PIL import Image
import torch
import torch.nn as nn
import torch.distributed as dist
import torch.backends.cudnn as cudnn
import torch.nn.functional as F
from torchvision import dat... | 10,172 | 35.858696 | 123 | py |
HIPT | HIPT-master/HIPT_4K/hipt_model_utils.py | ### Dependencies
# Base Dependencies
import argparse
import colorsys
from io import BytesIO
import os
import random
import requests
import sys
# LinAlg / Stats / Plotting Dependencies
import cv2
import h5py
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import numpy as np
from... | 5,125 | 32.503268 | 122 | py |
HIPT | HIPT-master/HIPT_4K/attention_visualization_utils.py | ### Dependencies
import argparse
import colorsys
from io import BytesIO
import os
import random
import requests
import sys
import cv2
import h5py
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import numpy as np
from PIL import Image
from PIL import ImageFont
from PIL import I... | 36,576 | 44.10111 | 141 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/main.py | ### Base Packages
from __future__ import print_function
import argparse
import pdb
import os
import math
### Numerical Packages
import numpy as np
import pandas as pd
### Internal Imports
from datasets.dataset_generic import Generic_WSI_Classification_Dataset, Generic_MIL_Dataset
from utils.file_utils import save_pkl... | 12,119 | 45.259542 | 157 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_utils.py | from collections import OrderedDict
from os.path import join
import math
import pdb
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
"""
Attention Network without Gating (2 fc layers)
args:
L: input feature dimension
D: hidden layer dimension
dropout: whether to use ... | 2,562 | 25.978947 | 77 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_dgcn.py | from os.path import join
from collections import OrderedDict
import pdb
import numpy as np
import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Sequential as Seq
from torch.nn import Linear, LayerNorm, ReLU
#from torch_geometric.nn import GINConv
#from torch_geometric.transforms.nor... | 3,422 | 41.7875 | 116 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_mil.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from utils.utils import initialize_weights
import numpy as np
class MIL_fc(nn.Module):
def __init__(self, path_input_dim=384, gate = True, size_arg = "small", dropout = False, n_classes = 2, top_k=1):
super(MIL_fc, self).__init__()
... | 3,647 | 36.22449 | 121 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_clam.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from utils.utils import initialize_weights
import numpy as np
from models.model_utils import *
"""
args:
gate: whether to use gated attention network
size_arg: config for network size
dropout: whether to use dropout
k_sample: number of ... | 9,447 | 43.990476 | 128 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_hierarchical_mil.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import pdb
import numpy as np
from os.path import join
from collections import OrderedDict
import torch
import torch.nn as nn
import torch.nn.functional as F
from models.model_utils import *
import sys
sys.path.append('../HIPT_4K/')
from vision_trans... | 8,672 | 39.528037 | 116 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_dsmil.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class FCLayer(nn.Module):
def __init__(self, in_size, out_size=1):
super(FCLayer, self).__init__()
self.fc = nn.Sequential(nn.Linear(in_size, out_size))
def forward(self, feats, **kwargs):
... | 3,324 | 43.333333 | 168 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_cluster.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import pdb
import numpy as np
from os.path import join
from collections import OrderedDict
import torch
import torch.nn as nn
import torch.nn.functional as F
######################################
# Deep Attention MISL Implementation #
###############... | 3,697 | 37.520833 | 108 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/resnet_custom.py | # modified from Pytorch official resnet.py
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
import torch
from torchsummary import summary
import torch.nn.functional as F
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152']
model_urls = {
'resnet18': 'https:/... | 4,314 | 32.976378 | 90 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/datasets/dataset_generic.py | from __future__ import print_function, division
import os
import torch
import numpy as np
import pandas as pd
import math
import re
import pdb
import pickle
from scipy import stats
from torch.utils.data import Dataset
import h5py
from utils.utils import generate_split, nth
def save_splits(split_datasets, column_keys... | 16,504 | 38.204276 | 167 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/datasets/dataset_h5.py | from __future__ import print_function, division
import os
import torch
import numpy as np
import pandas as pd
import math
import re
import pdb
import pickle
from torch.utils.data import Dataset, DataLoader, sampler
from torchvision import transforms, utils, models
import torch.nn.functional as F
from PIL import Image... | 4,426 | 24.738372 | 104 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/datasets/BatchWSI.py | import torch_geometric
from typing import List
import torch
from torch import Tensor
from torch_sparse import SparseTensor, cat
import torch_geometric
from torch_geometric.data import Data
class BatchWSI(torch_geometric.data.Batch):
def __init__(self):
super(BatchWSI, self).__init__()
pass
... | 6,596 | 42.98 | 93 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/utils/core_utils.py | import numpy as np
import torch
import torch.nn.functional as F
from utils.utils import *
import os
import torch.nn.functional as F
from datasets.dataset_generic import save_splits
from models.model_dsmil import *
from models.model_mil import MIL_fc, MIL_fc_mc
from models.model_dgcn import DeepGraphConv
from models.mod... | 23,019 | 36.986799 | 163 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/utils/utils.py | import pickle
import torch
import numpy as np
import torch.nn as nn
import pdb
import torch
import numpy as np
import torch.nn as nn
from torchvision import transforms
from torch.utils.data import DataLoader, Sampler, WeightedRandomSampler, RandomSampler, SequentialSampler, sampler
import torch.optim as optim
import p... | 6,214 | 32.413978 | 197 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/utils/eval_utils.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from models.model_mil import MIL_fc, MIL_fc_mc
from models.model_clam import CLAM_SB, CLAM_MB
import pdb
import os
import pandas as pd
from utils.utils import *
from utils.core_utils import Accuracy_Logger
from sklearn.metrics import... | 4,650 | 33.451852 | 114 | py |
benchmarking_graph | benchmarking_graph-main/src/md.py | from functools import partial
import jax
import jax.numpy as jnp
from jax import jit, lax, value_and_grad
from jax.experimental import optimizers
from .nve import nve, nve2, nve3
# ===============================
# ===============================
def dynamics_generator(ensemble, force_fn, shift_fn, params, dt, ma... | 5,251 | 27.699454 | 83 | py |
benchmarking_graph | benchmarking_graph-main/src/hamiltonian.py | import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import numpy as np
from jax.experimental import ode
# from shadow.plot import panel
def hamiltonian(x, p, params):
"""
hamiltonian calls lnn._H
x: Vector
p: Vector
"""
return None
def ps(*args):
for i in args:
pri... | 3,630 | 25.698529 | 91 | py |
benchmarking_graph | benchmarking_graph-main/src/utils.py | import importlib
from functools import partial
import jax
import jax.numpy as jnp
import jax_md
import numpy as np
from jax import grad, jit, random, vmap
from jax_md import smap
from . import lnn, models
def colnum(i, j, N):
"""Gives linear index for upper triangle matrix.
"""
assert (j >= i), "j >= i,... | 9,647 | 31.928328 | 99 | py |
benchmarking_graph | benchmarking_graph-main/src/graph.py | # Copyright 2020 DeepMind Technologies Limited.
# 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 t... | 63,572 | 35.620392 | 100 | py |
benchmarking_graph | benchmarking_graph-main/src/fgn1.py | from functools import partial
import haiku as hk
import jax
import jax.numpy as jnp
import numpy as np
from jax import grad, jit, lax, random
from jax_md.nn import GraphNetEncoder
from jraph import GraphMapFeatures, GraphNetwork, GraphsTuple
from src.models import SquarePlus, forward_pass, initialize_mlp
class Grap... | 4,353 | 30.781022 | 99 | py |
benchmarking_graph | benchmarking_graph-main/src/nve.py | # Copyright 2019 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,149 | 35.454183 | 86 | py |
benchmarking_graph | benchmarking_graph-main/src/graph1.py | # Copyright 2020 DeepMind Technologies Limited.
# 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 t... | 47,723 | 33.408075 | 141 | py |
benchmarking_graph | benchmarking_graph-main/src/lnn.py | from functools import partial
import jax
import jax.numpy as jnp
import numpy as np
from jax import grad, jit, vmap
from numpy.core.fromnumeric import reshape
from .models import ReLU, SquarePlus, forward_pass
def MAP(input_fn):
"""Map vmap for first input.
:param input_fn: function to map
:type input_... | 11,352 | 26.030952 | 149 | py |
benchmarking_graph | benchmarking_graph-main/src/Pendulum-LGNN-post-rk.py | ################################################
################## IMPORT ######################
################################################
# from fcntl import F_SEAL_SEAL
import json
import sys
import os
from datetime import datetime
from functools import partial, wraps
from statistics import mode
import fire... | 17,099 | 31.447818 | 166 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.