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 |
|---|---|---|---|---|---|---|
TiKick | TiKick-main/setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2021 The TARTRL Authors.
#
# 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
#
# Unle... | 1,788 | 35.510204 | 74 | py |
TiKick | TiKick-main/tmarl/networks/policy_network.py |
import torch
import torch.nn as nn
from tmarl.networks.utils.util import init, check
from tmarl.networks.utils.mlp import MLPBase, MLPLayer
from tmarl.networks.utils.rnn import RNNLayer
from tmarl.networks.utils.act import ACTLayer
from tmarl.networks.utils.popart import PopArt
from tmarl.utils.util import get_shape_... | 5,558 | 41.113636 | 181 | py |
TiKick | TiKick-main/tmarl/networks/utils/distributions.py | import torch
import torch.nn as nn
from .util import init
"""
Modify standard PyTorch distributions so they are compatible with this code.
"""
#
# Standardize distribution interfaces
#
# Categorical
class FixedCategorical(torch.distributions.Categorical):
def sample(self):
return super().sample().unsque... | 3,466 | 27.891667 | 86 | py |
TiKick | TiKick-main/tmarl/networks/utils/mlp.py |
import torch.nn as nn
from .util import init, get_clones
class MLPLayer(nn.Module):
def __init__(self, input_dim, hidden_size, layer_N, use_orthogonal, activation_id):
super(MLPLayer, self).__init__()
self._layer_N = layer_N
active_func = [nn.Tanh(), nn.ReLU(), nn.LeakyReLU(), nn.ELU()]... | 2,116 | 32.603175 | 98 | py |
TiKick | TiKick-main/tmarl/networks/utils/popart.py | import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class PopArt(torch.nn.Module):
def __init__(self, input_shape, output_shape, norm_axes=1, beta=0.99999, epsilon=1e-5, device=torch.device("cpu")):
super(PopArt, self).__init__()
self.bet... | 3,796 | 38.968421 | 119 | py |
TiKick | TiKick-main/tmarl/networks/utils/util.py |
import copy
import numpy as np
import torch
import torch.nn as nn
def init(module, weight_init, bias_init, gain=1):
weight_init(module.weight.data, gain=gain)
bias_init(module.bias.data)
return module
def get_clones(module, N):
return nn.ModuleList([copy.deepcopy(module) for i in range(N)])
def che... | 426 | 21.473684 | 76 | py |
TiKick | TiKick-main/tmarl/networks/utils/act.py |
from .distributions import Bernoulli, Categorical, DiagGaussian
import torch
import torch.nn as nn
class ACTLayer(nn.Module):
def __init__(self, action_space, inputs_dim, use_orthogonal, gain):
super(ACTLayer, self).__init__()
self.multidiscrete_action = False
self.continuous_action = Fal... | 7,195 | 46.342105 | 121 | py |
TiKick | TiKick-main/tmarl/networks/utils/rnn.py |
import torch
import torch.nn as nn
class RNNLayer(nn.Module):
def __init__(self, inputs_dim, outputs_dim, recurrent_N, use_orthogonal):
super(RNNLayer, self).__init__()
self._recurrent_N = recurrent_N
self._use_orthogonal = use_orthogonal
self.rnn = nn.GRU(inputs_dim, outputs_dim... | 2,816 | 34.2125 | 132 | py |
TiKick | TiKick-main/tmarl/drivers/shared_distributed/base_driver.py | import numpy as np
import torch
def _t2n(x):
return x.detach().cpu().numpy()
class Driver(object):
def __init__(self, config, client=None):
self.all_args = config['all_args']
self.envs = config['envs']
self.eval_envs = config['eval_envs']
self.device = config['device']
... | 4,244 | 39.04717 | 126 | py |
TiKick | TiKick-main/tmarl/algorithms/r_mappo_distributed/mappo_algorithm.py | import torch
from tmarl.utils.valuenorm import ValueNorm
# implement the loss of the MAPPO here
class MAPPOAlgorithm():
def __init__(self,
args,
init_module,
device=torch.device("cpu")):
self.device = device
self.tpdv = dict(dtype=torch.float32, ... | 2,234 | 38.210526 | 147 | py |
TiKick | TiKick-main/tmarl/algorithms/r_mappo_distributed/mappo_module.py | import torch
from tmarl.networks.policy_network import PolicyNetwork
class MAPPOModule:
def __init__(self, args, obs_space, share_obs_space, act_space, device=torch.device("cpu")):
self.device = device
self.lr = args.lr
self.critic_lr = args.critic_lr
self.opti_eps = args.... | 1,050 | 41.04 | 135 | py |
TiKick | TiKick-main/tmarl/replay_buffers/normal/shared_buffer.py | import torch
import numpy as np
from collections import defaultdict
from tmarl.utils.util import check,get_shape_from_obs_space, get_shape_from_act_space
def _flatten(T, N, x):
return x.reshape(T * N, *x.shape[2:])
def _cast(x):
return x.transpose(1, 2, 0, 3).reshape(-1, *x.shape[3:])
class SharedReplayBuff... | 28,769 | 52.081181 | 231 | py |
TiKick | TiKick-main/tmarl/configs/config.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2021 The TARTRL Authors.
#
# 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
#
# Unle... | 10,665 | 55.734043 | 146 | py |
TiKick | TiKick-main/tmarl/runners/base_evaluator.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2021 The TARTRL Authors.
#
# 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
#
# Unle... | 3,402 | 28.08547 | 97 | py |
TiKick | TiKick-main/tmarl/runners/base_runner.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2021 The TARTRL Authors.
#
# 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
#
# Unle... | 1,079 | 22.478261 | 74 | py |
TiKick | TiKick-main/tmarl/utils/valuenorm.py |
import numpy as np
import torch
import torch.nn as nn
class ValueNorm(nn.Module):
""" Normalize a vector of observations - across the first norm_axes dimensions"""
def __init__(self, input_shape, norm_axes=1, beta=0.99999, per_element_update=False, epsilon=1e-5, device=torch.device("cpu")):
super(V... | 3,110 | 37.8875 | 131 | py |
TiKick | TiKick-main/tmarl/utils/util.py |
import copy
import numpy as np
import math
import gym
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.distributed as dist
from torch.autograd import Variable
from gym.spaces import Box, Discrete, Tuple
def check(input):
if type(input) == np.ndarray:
return torch.from_numpy... | 13,893 | 31.846336 | 122 | py |
TiKick | TiKick-main/tmarl/utils/gpu_mem_track.py | # code from https://github.com/Oldpan/Pytorch-Memory-Utils
import gc
import datetime
import inspect
import torch
import numpy as np
dtype_memory_size_dict = {
torch.float64: 64/8,
torch.double: 64/8,
torch.float32: 32/8,
torch.float: 32/8,
torch.float16: 16/8,
torch.half: 16/8,
torch.int6... | 4,432 | 36.888889 | 129 | py |
TiKick | TiKick-main/tmarl/utils/modelsize_estimate.py | # code from https://github.com/Oldpan/Pytorch-Memory-Utils
import torch.nn as nn
import numpy as np
def modelsize(model, input, type_size=4):
para = sum([np.prod(list(p.size())) for p in model.parameters()])
# print('Model {} : Number of params: {}'.format(model._get_name(), para))
print('Model {} : para... | 1,428 | 34.725 | 116 | py |
RobDanns | RobDanns-main/deep_learning/tools/corruptions-inference-tinyimagenet.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 25,928 | 41.092532 | 139 | py |
RobDanns | RobDanns-main/deep_learning/tools/train_resnet18_on_tinyimagenet200.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 21,617 | 37.741935 | 129 | py |
RobDanns | RobDanns-main/deep_learning/tools/adversarial-inference-tinyimagenet200.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 23,184 | 38.768439 | 147 | py |
RobDanns | RobDanns-main/deep_learning/tools/adversarial-inference.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 23,798 | 41.72711 | 166 | py |
RobDanns | RobDanns-main/deep_learning/tools/corruptions-inference.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 23,864 | 42.708791 | 139 | py |
RobDanns | RobDanns-main/deep_learning/tools/train_net.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 18,692 | 39.113734 | 127 | py |
RobDanns | RobDanns-main/deep_learning/pycls/config.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 10,201 | 24.378109 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/losses.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 730 | 26.074074 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/efficientnet.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 15,385 | 33.809955 | 108 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/resnet.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory of ... | 20,015 | 37.198473 | 108 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/cnn.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 17,388 | 34.779835 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/vgg.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 3,097 | 35.880952 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/mlp.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 8,012 | 30.300781 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/model_builder.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 2,355 | 30 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/mobilenet.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 3,404 | 35.223404 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/optimizer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 1,678 | 27.457627 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/models/relation_graph.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 15,045 | 35.877451 | 114 | py |
RobDanns | RobDanns-main/deep_learning/pycls/datasets/cifar100.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 3,163 | 34.155556 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/datasets/cifar10.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 3,048 | 33.647727 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/datasets/loader.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 3,131 | 30.009901 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/datasets/imagenet.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 6,759 | 35.344086 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/utils/checkpoint.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 4,392 | 31.540741 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/utils/net.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 4,360 | 37.59292 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/utils/distributed.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 2,323 | 31.277778 | 107 | py |
RobDanns | RobDanns-main/deep_learning/pycls/utils/metrics.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the original graph2nn github repo.
# File modifications and additions by Rowan AI Lab, licensed under the Creative Commons Zero v1.0 Universal
# LICENSE file in the root directory ... | 8,557 | 33.095618 | 158 | py |
kge_ecotox_regression | kge_ecotox_regression-main/main.py |
"""
TODO:
- Train embedding model.
- Apply embeddings to data.
- Encode data.
- Train,valid,test model
"""
from autoencoder import create_auto_encoder
from model import create_model, CorrelelatedFeatures, ApproxKerasSVM, coeff_determination
import numpy as np
import pandas as pd
from sklearn.model... | 32,681 | 35.394209 | 169 | py |
kge_ecotox_regression | kge_ecotox_regression-main/embedding_model.py | from tensorflow.keras import Model, Sequential
from tensorflow.keras.layers import Input, Embedding, Dense, Dropout, Conv2D, Flatten, Concatenate, Multiply
import tensorflow as tf
def min_distance_loss(w,epsilon=1.0):
r = tf.reduce_sum(w*w, 1)
r = tf.reshape(r, [-1, 1])
D = r - 2*tf.matmul(w, tf.... | 4,177 | 31.897638 | 108 | py |
kge_ecotox_regression | kge_ecotox_regression-main/pretrained_embedding_models.py |
import sys
import os
from itertools import product
from KGEkeras import DistMult, HolE, TransE, HAKE, ConvE, ComplEx, ConvR, RotatE, pRotatE, ConvKB, CosinE
from kerastuner import RandomSearch, HyperParameters, Objective, Hyperband, BayesianOptimization
from random import choice
from collections import defaultdict
... | 8,625 | 30.140794 | 134 | py |
kge_ecotox_regression | kge_ecotox_regression-main/autoencoder.py |
from tensorflow.keras.layers import Dense, GaussianNoise, Input, LayerNormalization
from tensorflow.keras.models import Model
from tensorflow import keras
def create_auto_encoder(input_size, dense_layers = (10,), noise=0):
autoencoder = keras.Sequential()
if noise > 0:
autoencoder.add(GaussianNoise(no... | 613 | 33.111111 | 83 | py |
lepard | lepard-main/main.py | import os, torch, json, argparse, shutil
from easydict import EasyDict as edict
import yaml
from datasets.dataloader import get_dataloader, get_datasets
from models.pipeline import Pipeline
from lib.utils import setup_seed
from lib.tester import get_trainer
from models.loss import MatchMotionLoss
from lib.tictok import... | 3,723 | 32.54955 | 116 | py |
lepard | lepard-main/models/matching.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from models.position_encoding import VolumetricPositionEncoding as VolPE
def log_optimal_transport(scores, alpha, iters, src_mask, tgt_mask ):
b, m, n = scores.shape
if src_mask is None:
ms = m
ns = n
else :
ms = s... | 5,412 | 29.931429 | 118 | py |
lepard | lepard-main/models/loss.py | import torch
import torch.nn as nn
import numpy as np
import open3d as o3d
from lib.benchmark_utils import to_o3d_pcd
from lib.visualization import *
import nibabel.quaternions as nq
from sklearn.metrics import precision_recall_fscore_support
from datasets.utils import blend_scene_flow, multual_nn_correspondence, knn_p... | 18,271 | 38.042735 | 137 | py |
lepard | lepard-main/models/position_encoding.py | import math
import torch
from torch import nn
class VolumetricPositionEncoding(nn.Module):
def __init__(self, config):
super().__init__()
self.feature_dim = config.feature_dim
self.vol_bnds = config.vol_bnds
self.voxel_size = config.voxel_size
self.vol_origin = self.vol_b... | 2,989 | 33.367816 | 160 | py |
lepard | lepard-main/models/backbone.py | from models.blocks import *
import torch.nn.functional as F
import numpy as np
class KPFCN(nn.Module):
def __init__(self, config):
super(KPFCN, self).__init__()
############
# Parameters
############
layer = 0
r = config.first_subsampling_dl * config.conv_radius
... | 6,033 | 36.018405 | 100 | py |
lepard | lepard-main/models/transformer.py | import copy
import math
import torch
from torch import nn
from torch.nn import Module, Dropout
from models.position_encoding import VolumetricPositionEncoding as VolPE
from models.matching import Matching
from models.procrustes import SoftProcrustesLayer
import numpy as np
import random
from scipy.spatial.transform imp... | 10,666 | 36.559859 | 142 | py |
lepard | lepard-main/models/procrustes.py | import torch
import torch.nn as nn
def topk(data, num_topk):
sort, idx = data.sort(descending=True)
return sort[:num_topk], idx[:num_topk]
class SoftProcrustesLayer(nn.Module):
def __init__(self, config):
super(SoftProcrustesLayer, self).__init__()
self.sample_rate = config.sample_rate
... | 3,591 | 37.623656 | 107 | py |
lepard | lepard-main/models/pipeline.py | from models.blocks import *
from models.backbone import KPFCN
from models.transformer import RepositioningTransformer
from models.matching import Matching
from models.procrustes import SoftProcrustesLayer
class Pipeline(nn.Module):
def __init__(self, config):
super(Pipeline, self).__init__()
self.... | 3,685 | 43.95122 | 154 | py |
lepard | lepard-main/models/blocks.py | import time
import math
import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
from torch.nn.init import kaiming_uniform_
from kernels.kernel_points import load_kernels
# from lib.ply import write_ply
def gather(x, idx, method=2):
"""
implementation of a custom gather operation for faste... | 26,090 | 35.956091 | 122 | py |
lepard | lepard-main/datasets/_4dmatch.py | import os, sys, glob, torch
# sys.path.append("../")
[sys.path.append(i) for i in ['.', '..']]
import numpy as np
import torch
import random
from scipy.spatial.transform import Rotation
from torch.utils.data import Dataset
from lib.benchmark_utils import to_o3d_pcd, to_tsfm, KDTree_corr
from lib.utils import load_obj
H... | 5,939 | 32.75 | 123 | py |
lepard | lepard-main/datasets/dataloader.py | import numpy as np
from functools import partial
import torch
import cpp_wrappers.cpp_subsampling.grid_subsampling as cpp_subsampling
import cpp_wrappers.cpp_neighbors.radius_neighbors as cpp_neighbors
from datasets._3dmatch import _3DMatch
from datasets._4dmatch import _4DMatch
from datasets.utils import blend_scene_f... | 24,996 | 37.875583 | 171 | py |
lepard | lepard-main/datasets/_3dmatch.py | import os, sys, glob, torch
# sys.path.append("../")
[sys.path.append(i) for i in ['.', '..']]
import numpy as np
import torch
import random
from scipy.spatial.transform import Rotation
from torch.utils.data import Dataset
from lib.benchmark_utils import to_o3d_pcd, to_tsfm, KDTree_corr
from lib.utils import load_obj
... | 5,766 | 33.327381 | 116 | py |
lepard | lepard-main/lib/tester.py | from lib.trainer import Trainer
import torch
from tqdm import tqdm
from models.loss import MatchMotionLoss as MML
import numpy as np
from models.matching import Matching as CM
import math
class _3DMatchTester(Trainer):
"""
3DMatch tester
"""
def __init__(self,args):
Trainer.__init__(self, args)... | 10,544 | 34.385906 | 164 | py |
lepard | lepard-main/lib/benchmark_utils.py | import os,re,sys,json,yaml,random, glob, argparse, torch, pickle
from tqdm import tqdm
import numpy as np
from scipy.spatial.transform import Rotation
import open3d as o3d
_EPS = 1e-7 # To prevent division by zero
def viz_coarse_nn_correspondence_mayavi(s_pc, t_pc, good_c, bad_c, f_src_pcd=None, f_tgt_pcd=None, sca... | 11,442 | 31.882184 | 122 | py |
lepard | lepard-main/lib/utils.py | import os,re,sys,json,yaml,random, argparse, torch, pickle
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
from scipy.spatial.transform import Rotation
from sklearn.neighbors import NearestNeighbors
from scipy.spatial.distance import minkowski
_EPS = 1e-7 # To prev... | 2,759 | 23.424779 | 82 | py |
lepard | lepard-main/lib/trainer.py | import gc
import os
import torch
import torch.nn as nn
import numpy as np
from tensorboardX import SummaryWriter
from tqdm import tqdm
from lib.timer import AverageMeter
from lib.utils import Logger, validate_gradient
from lib.tictok import Timers
class Trainer(object):
def __init__(self, args):
self.c... | 8,861 | 34.590361 | 117 | py |
sngan.pytorch | sngan.pytorch-master/test.py | # -*- coding: utf-8 -*-
# @Date : 2019-07-25
# @Author : Xinyu Gong (xy_gong@tamu.edu)
# @Link : None
# @Version : 0.0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import cfg
import models
from functions import validate
from utils.utils import set... | 2,425 | 29.708861 | 88 | py |
sngan.pytorch | sngan.pytorch-master/functions.py | # -*- coding: utf-8 -*-
# @Date : 2019-07-25
# @Author : Xinyu Gong (xy_gong@tamu.edu)
# @Link : None
# @Version : 0.0
import os
import numpy as np
import torch
import torch.nn as nn
from torchvision.utils import make_grid
from imageio import imsave
from tqdm import tqdm
from copy import deepcopy
import logging... | 6,022 | 32.837079 | 123 | py |
sngan.pytorch | sngan.pytorch-master/datasets.py | import torch
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from torch.utils.data import Dataset
class ImageDataset(object):
def __init__(self, args):
if args.dataset.lower() == 'cifar10':
Dt = datasets.CIFAR10
transform = transforms.Compose([
... | 2,115 | 40.490196 | 101 | py |
sngan.pytorch | sngan.pytorch-master/train.py | # -*- coding: utf-8 -*-
# @Date : 2019-07-25
# @Author : Xinyu Gong (xy_gong@tamu.edu)
# @Link : None
# @Version : 0.0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import cfg
import models
import datasets
from functions import train, validate, Lin... | 6,393 | 37.287425 | 116 | py |
sngan.pytorch | sngan.pytorch-master/models/sngan_64.py | import torch.nn as nn
class GenBlock(nn.Module):
def __init__(self, in_channels, out_channels, hidden_channels=None, ksize=3, pad=1,
activation=nn.ReLU(), upsample=False, n_classes=0):
super(GenBlock, self).__init__()
self.activation = activation
self.upsample = upsample
... | 6,296 | 34.778409 | 107 | py |
sngan.pytorch | sngan.pytorch-master/models/sngan_stl10.py | import torch.nn as nn
class GenBlock(nn.Module):
def __init__(self, in_channels, out_channels, hidden_channels=None, ksize=3, pad=1,
activation=nn.ReLU(), upsample=False, n_classes=0):
super(GenBlock, self).__init__()
self.activation = activation
self.upsample = upsample
... | 6,305 | 34.426966 | 99 | py |
sngan.pytorch | sngan.pytorch-master/models/sngan_cifar10.py | import torch.nn as nn
from .gen_resblock import GenBlock
class Generator(nn.Module):
def __init__(self, args, activation=nn.ReLU(), n_classes=0):
super(Generator, self).__init__()
self.bottom_width = args.bottom_width
self.activation = activation
self.n_classes = n_classes
... | 4,805 | 34.338235 | 107 | py |
sngan.pytorch | sngan.pytorch-master/models/gen_resblock.py | # -*- coding: utf-8 -*-
# @Date : 3/26/20
# @Author : Xinyu Gong (xy_gong@tamu.edu)
# @Link : None
# @Version : 0.0
import torch.nn as nn
class GenBlock(nn.Module):
def __init__(self, in_channels, out_channels, hidden_channels=None, ksize=3, pad=1,
activation=nn.ReLU(), upsample=False, n_... | 1,671 | 33.833333 | 90 | py |
sngan.pytorch | sngan.pytorch-master/utils/utils.py | # -*- coding: utf-8 -*-
# @Date : 2019-07-25
# @Author : Xinyu Gong (xy_gong@tamu.edu)
# @Link : None
# @Version : 0.0
import os
import torch
import dateutil.tz
from datetime import datetime
import time
import logging
def create_logger(log_dir, phase='train'):
time_str = time.strftime('%Y-%m-%d-%H-%M')
... | 1,772 | 26.703125 | 75 | py |
neu-nbv | neu-nbv-main/scripts/planning/dtu_experiment.py | import sys
import os
root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.insert(0, root_dir)
from neural_rendering.evaluation.pretrained_model import PretrainedModel
from neural_rendering.data import get_data
from neural_rendering.utils import parser, util
import yaml
from dotmap import... | 13,632 | 34.046272 | 113 | py |
neu-nbv | neu-nbv-main/scripts/planning/simulator_experiment.py | import rospy
import os
import sys
root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.insert(0, root_dir)
import yaml
import argparse
from planner import get_planner
from planner.utils import uniform_sampling
import numpy as np
import scipy.spatial as spatial
from datetime import dateti... | 9,450 | 29.685065 | 94 | py |
neu-nbv | neu-nbv-main/scripts/planning/planner/neural_nbv/neural_nbv_planner.py | import numpy as np
from scipy.spatial.transform import Rotation as R
from planner.planner import Planner
from planner.utils import view_to_pose_batch, random_view, uniform_sampling
from neural_rendering.evaluation.pretrained_model import PretrainedModel
import torch
from dotmap import DotMap
from neural_rendering.utils... | 8,864 | 33.901575 | 88 | py |
fitclip | fitclip-main/util/structured_group_utils.py | """Useful utils when using `DataModuleStructuredGroup`."""
from typing import Any, Mapping, Sequence, Tuple
import torch
from aligner.video_text_module import TYPE_INPUT
from util.tensor_utils import pad
TYPE_MULTI_INPUT = Mapping[str, TYPE_INPUT]
# It's like `default_collate` but instead of a sequence we have a m... | 1,737 | 40.380952 | 110 | py |
fitclip | fitclip-main/util/viz_utils.py | import numpy as np
import torch
import torchvision
from matplotlib import pyplot as plt
from matplotlib.pyplot import subplots_adjust
from torchvision.transforms.functional import to_pil_image
from aligner.encoder.video_text_encoder import VideoTextEncoder
def visualize_images_tensor(images: torch.Tensor) -> plt.Axe... | 1,139 | 29 | 95 | py |
fitclip | fitclip-main/util/tensor_utils.py | from typing import Any, Mapping, Optional, Sequence, TypeVar, Union
import pytorch_lightning as pl
import torch
import torch.nn.functional as F
from pytorch_lightning.utilities.apply_func import apply_to_collection
T = TypeVar("T")
def pad(t: torch.Tensor, min_size: int, dim: int = 1, value: Any = 0) -> torch.Tenso... | 3,355 | 49.089552 | 120 | py |
fitclip | fitclip-main/util/checkpoint_utils.py | from typing import MutableMapping
import torch
from cached_path import cached_path
from util.typing_utils import TYPE_PATH
def state_dict_from_checkpoint_path(checkpoint_path: TYPE_PATH, prefix: str = "") -> MutableMapping[str, torch.Tensor]:
prefix += ("" if prefix.endswith(".") or not prefix else ".")
che... | 472 | 35.384615 | 119 | py |
fitclip | fitclip-main/util/video_utils.py | import os
from typing import Any, Callable, Iterable, Iterator, Optional, Sequence
from torchvision.datasets.video_utils import VideoClips
from util.typing_utils import TYPE_PATH
# From https://en.wikipedia.org/wiki/Video_file_format
VIDEO_FILE_EXTENSIONS = (".3g2", ".3gp", ".amv", ".asf", ".avi", ".drc", ".f4a", ".... | 2,659 | 53.285714 | 119 | py |
fitclip | fitclip-main/scripts/apply_wise_ft.py | #!/usr/bin/env python
import argparse
import torch
from aligner.encoder.clip_video_text_encoder import load_clip_model
from aligner.wise import wise_state_dict
from util.argparse_with_defaults import ArgumentParserWithDefaults
def parse_args() -> argparse.Namespace:
parser = ArgumentParserWithDefaults("Applies ... | 1,526 | 37.175 | 116 | py |
fitclip | fitclip-main/scripts/subcorr.py | #!/usr/bin/env python
import argparse
import sys
from typing import Any, Callable, Iterable, MutableMapping, Optional, Sequence, Union
import PIL.Image
import clip
import decord
import numpy as np
import seaborn as sns
import torch
from clip.model import CLIP
from matplotlib import pyplot as plt
from matplotlib.offset... | 4,981 | 35.101449 | 109 | py |
fitclip | fitclip-main/scripts/prepare_trained_clip_checkpoint_for_evaluation.py | #!/usr/bin/env python
import argparse
import torch
from util.checkpoint_utils import state_dict_from_checkpoint_path
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("input_path", metavar="INPUT_FILE")
parser.add_argument("output_path", metavar="OUTPUT_FILE"... | 868 | 27.032258 | 116 | py |
fitclip | fitclip-main/scripts/checkpoint_to_state_dict.py | #!/usr/bin/env python
import argparse
import sys
import torch
from util.checkpoint_utils import state_dict_from_checkpoint_path
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("input_path", metavar="INPUT_FILE")
parser.add_argument("--prefix", default="enco... | 582 | 22.32 | 85 | py |
fitclip | fitclip-main/scripts/prepare_trained_checkpoint_for_evaluation.py | #!/usr/bin/env python
import argparse
import torch
from cached_path import cached_path
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("input_path", metavar="INPUT_FILE", type=cached_path)
parser.add_argument("output_path", metavar="OUTPUT_FILE")
parser.... | 771 | 26.571429 | 120 | py |
fitclip | fitclip-main/scripts/open_clip_checkpoint_to_model.py | #!/usr/bin/env python
import argparse
import torch
from cached_path import cached_path
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("input_path", metavar="INPUT_FILE", type=cached_path)
parser.add_argument("output_path", metavar="OUTPUT_FILE")
return ... | 744 | 25.607143 | 97 | py |
fitclip | fitclip-main/aligner/video_text_module.py | from typing import Any, Literal, Mapping, MutableMapping, Optional, Sequence, Tuple, Union
import math
import pytorch_lightning as pl
import torch.distributed.nn
from overrides import overrides
from torch import nn
from torch.nn.modules.loss import _Loss
from aligner.encoder.video_text_encoder import TYPE_OUTPUT, Vid... | 4,376 | 43.663265 | 116 | py |
fitclip | fitclip-main/aligner/__main__.py | #!/usr/bin/env python
import logging
import os
from time import strftime
from typing import Mapping, Optional
import hydra
import torch
from omegaconf import DictConfig
from pytorch_lightning.loggers import NeptuneLogger, TensorBoardLogger
from aligner.cli import create_model_data_module_trainer_and_ckpt_path, init_c... | 4,715 | 43.490566 | 118 | py |
fitclip | fitclip-main/aligner/logger_utils.py | from typing import Optional, Type, TypeVar
import pytorch_lightning as pl
from pytorch_lightning.loggers import LightningLoggerBase, LoggerCollection
T = TypeVar("T", bound=LightningLoggerBase)
def get_logger_by_type(trainer: pl.Trainer, logger_class: Type[T]) -> Optional[T]:
if isinstance(trainer.logger, Logg... | 564 | 32.235294 | 117 | py |
fitclip | fitclip-main/aligner/teacher_student.py | import itertools
from typing import Iterable, Mapping, MutableMapping, Optional, Tuple, Union
import torch.distributed.nn
from overrides import overrides
from torch import nn
from aligner.encoder import video_text_encoder
from aligner.encoder.video_text_encoder import TYPE_TOKENIZER, VideoTextEncoder
from aligner.los... | 10,735 | 54.05641 | 117 | py |
fitclip | fitclip-main/aligner/loss.py | from typing import Literal
import torch
from overrides import overrides
from torch.nn import functional as F
from torch.nn.modules.loss import _Loss
TYPE_REDUCTION = Literal["none", "mean", "sum"]
# noinspection SpellCheckingInspection
TYPE_REDUCTION_KL_DIV = Literal["none", "batchmean", "mean", "sum"]
def _rows_to... | 2,447 | 36.090909 | 105 | py |
fitclip | fitclip-main/aligner/text_video_retrieval.py | from collections import OrderedDict
from typing import Iterable, Mapping, Optional, Sequence, Tuple, Union
import torch
import torch.distributed.nn
from overrides import overrides
from torch import nn
from torchmetrics import Metric, Recall
from aligner.encoder.video_text_encoder import TYPE_OUTPUT
from aligner.metri... | 6,325 | 46.924242 | 115 | py |
fitclip | fitclip-main/aligner/video_text_classification.py | import logging
import math
from typing import Any, Iterable, Mapping, Optional, Sequence, TypeVar
import torch
from overrides import overrides
from pytorch_lightning.callbacks import RichProgressBar
from pytorch_lightning.utilities.apply_func import apply_to_collection
from torch import nn
from torchmetrics import Acc... | 6,045 | 41.879433 | 114 | py |
fitclip | fitclip-main/aligner/cli.py | #!/usr/bin/env python
import copy
import logging
import warnings
from types import MethodType
from typing import Any, Mapping, Optional, Tuple, Type
import hydra
import pytorch_lightning as pl
from cached_path import cached_path
from omegaconf import DictConfig
from pytorch_lightning import seed_everything
from torch.... | 6,809 | 44.099338 | 119 | py |
fitclip | fitclip-main/aligner/wise.py | import copy
from typing import Mapping, TypeVar
import torch
from torch import nn
T = TypeVar("T", bound=nn.Module)
def wise_state_dict(model1: T, model2: T, weight_for_2: float = 0.5) -> Mapping[str, torch.Tensor]:
state_dict1 = dict(model1.named_parameters())
state_dict2 = dict(model2.named_parameters())
... | 779 | 31.5 | 104 | py |
fitclip | fitclip-main/aligner/param_freezer.py | # Inspired from https://github.com/allenai/allennlp/blob/0d8c0fc/allennlp/training/optimizers.py
import logging
import re
from typing import Iterable, Optional, Union
import pytorch_lightning as pl
from overrides import overrides
LOGGER = logging.getLogger(__name__)
class ParamFreezer(pl.Callback):
def __init__... | 1,450 | 32.744186 | 113 | py |
fitclip | fitclip-main/aligner/metrics.py | import torch
from overrides import overrides
from torchmetrics import Metric
class Rank(Metric):
is_differentiable: bool = False
higher_is_better: bool = False
full_state_update: bool = False
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self.add_state("ranks", defa... | 1,162 | 30.432432 | 92 | py |
fitclip | fitclip-main/aligner/transforms.py | """From https://github.com/pytorch/vision/blob/993325d/references/video_classification/transforms.py"""
import random
from typing import Any
import torch
import torch.nn as nn
from overrides import overrides
from torchvision.transforms import InterpolationMode, RandomResizedCrop, functional as F
from util.tensor_util... | 2,123 | 33.258065 | 103 | py |
fitclip | fitclip-main/aligner/tests/data/multi_source_sampler_test.py | import string
from typing import Literal
from torch.utils.data import ConcatDataset, DataLoader, SequentialSampler
from aligner.data.multi_source_sampler import RoundRobinMultiSourceSampler
def _create_sample_data_loader(mode: Literal["min_size", "max_size_cycle"]) -> DataLoader:
dataset1 = string.ascii_lowerca... | 1,463 | 42.058824 | 117 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.