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 |
|---|---|---|---|---|---|---|
what-is-where-by-looking | what-is-where-by-looking-main/models/vgg16.py | import torch
import torch.nn as nn
from torchvision import models
class VGG16Net(nn.Module):
def __init__(self):
super(VGG16Net, self).__init__()
self.Org_model = models.vgg16(pretrained=True)
self.full_features = [64, 128, 256, 512, 512]
for param in self.Org_model.parameters():
... | 1,389 | 26.8 | 68 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/eval_retrieval_video.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 9,531 | 37.128 | 123 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/pretrain.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 6,666 | 37.537572 | 148 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/eval_nocaps.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 4,249 | 35.016949 | 119 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/utils.py | import math
def cosine_lr_schedule(optimizer, epoch, max_epoch, init_lr, min_lr):
"""Decay the learning rate"""
lr = (init_lr - min_lr) * 0.5 * (1. + math.cos(math.pi * epoch / max_epoch)) + min_lr
for param_group in optimizer.param_groups:
param_group['lr'] = lr
def warmup_lr_schedule(opti... | 8,474 | 29.485612 | 94 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/train_vqa.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 7,751 | 37.376238 | 128 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/train_nlvr.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 8,060 | 36.84507 | 123 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/train_retrieval.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 14,091 | 39.846377 | 129 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/train_caption.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 8,388 | 39.723301 | 128 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/predict.py | """
Download the weights in ./checkpoints beforehand for fast inference
wget https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model*_base_caption.pth
wget https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model*_vqa.pth
wget https://storage.googleapis.com/sfr-vision-language... | 3,796 | 37.353535 | 114 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/models/blip_pretrain.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
from BLIP.models.med import BertConfig, BertModel, BertLMHeadModel
from tra... | 16,076 | 46.285294 | 184 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/models/blip_vqa.py | from models.med import BertConfig, BertModel, BertLMHeadModel
from models.blip import create_vit, init_tokenizer, load_checkpoint
import torch
from torch import nn
import torch.nn.functional as F
from transformers import BertTokenizer
import numpy as np
class BLIP_VQA(nn.Module):
def __init__(self, ... | 8,969 | 47.225806 | 122 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/models/blip_retrieval.py | from BLIP.models.med import BertConfig, BertModel
from transformers import BertTokenizer
import torch
from torch import nn
import torch.nn.functional as F
from BLIP.models.blip import create_vit, init_tokenizer, load_checkpoint
class BLIP_Retrieval(nn.Module):
def __init__(self,
... | 13,769 | 42.03125 | 123 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/models/vit.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
* Based on timm code base
* https://github.com/rwightman/pytorch-image-models... | 14,240 | 45.691803 | 118 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/models/blip_itm.py | from BLIP.models.med import BertConfig, BertModel
from transformers import BertTokenizer
import os
import torch
from torch import nn
import torch.nn.functional as F
from BLIP.models.blip import create_vit, init_tokenizer, load_checkpoint
class BLIP_ITM(nn.Module):
def __init__(self,
... | 3,202 | 40.597403 | 119 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/models/blip_nlvr.py | from models.med import BertConfig
from models.nlvr_encoder import BertModel
from models.vit import interpolate_pos_embed
from models.blip import create_vit, init_tokenizer, is_url
from timm.models.hub import download_cached_file
import torch
from torch import nn
import torch.nn.functional as F
from transformers impor... | 4,398 | 41.708738 | 128 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/models/med.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
* Based on huggingface code base
* https://github.com/huggingface/transformer... | 41,786 | 42.710251 | 213 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/models/nlvr_encoder.py | import math
import os
import warnings
from dataclasses import dataclass
from typing import Optional, Tuple
import torch
from torch import Tensor, device, dtype, nn
import torch.utils.checkpoint
from torch import nn
from torch.nn import CrossEntropyLoss
import torch.nn.functional as F
from transformers.activations imp... | 36,738 | 42.529621 | 213 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/models/blip.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import warnings
warnings.filterwarnings("ignore")
from BLIP.models.vit imp... | 11,029 | 44.578512 | 128 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/data/nlvr_dataset.py | import os
import json
import random
from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
from data.utils import pre_caption
class nlvr_dataset(Dataset):
def __init__(self, transform, image_root, ann_root, split):
'''
image_root (string)... | 2,722 | 33.910256 | 111 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/data/pretrain_dataset.py | import json
import os
import random
from torch.utils.data import Dataset
from PIL import Image
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
Image.MAX_IMAGE_PIXELS = None
from data.utils import pre_caption
import os,glob
class pretrain_dataset(Dataset):
def __init__(self, ann_file, laion_path... | 1,632 | 26.677966 | 75 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/data/coco_karpathy_dataset.py | import os
import json
from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
from data.utils import pre_caption
class coco_karpathy_train(Dataset):
def __init__(self, transform, image_root, ann_root, max_words=30, prompt=''):
'''
im... | 4,711 | 36.396825 | 118 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/data/utils.py | import re
import json
import os
import torch
import torch.distributed as dist
import utils
def pre_caption(caption,max_words=50):
caption = re.sub(
r"([.!\"()*#:;~])",
' ',
caption.lower(),
)
caption = re.sub(
r"\s{2,}",
' ',
caption,
)
capti... | 3,449 | 29.803571 | 117 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/data/vqa_dataset.py | import os
import json
import random
from PIL import Image
import torch
from torch.utils.data import Dataset
from data.utils import pre_question
from torchvision.datasets.utils import download_url
class vqa_dataset(Dataset):
def __init__(self, transform, ann_root, vqa_root, vg_root, train_files=[], split="train")... | 3,454 | 38.261364 | 122 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/data/nocaps_dataset.py | import os
import json
from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
class nocaps_eval(Dataset):
def __init__(self, transform, image_root, ann_root, split):
urls = {'val':'https://storage.googleapis.com/sfr-vision-language-research/datase... | 1,139 | 34.625 | 111 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/data/video_dataset.py | from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
import torch
import numpy as np
import random
import decord
from decord import VideoReader
import json
import os
from data.utils import pre_caption
decord.bridge.set_bridge("torch")
class ImageNorm(object):... | 4,005 | 35.09009 | 122 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/data/__init__.py | import torch
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.transforms.functional import InterpolationMode
from data.coco_karpathy_dataset import coco_karpathy_train, coco_karpathy_caption_eval, coco_karpathy_retrieval_eval
from data.nocaps_dataset import nocaps_eval
from d... | 5,189 | 49.882353 | 127 | py |
what-is-where-by-looking | what-is-where-by-looking-main/BLIP/data/flickr30k_dataset.py | import os
import json
from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
from data.utils import pre_caption
class flickr30k_train(Dataset):
def __init__(self, transform, image_root, ann_root, max_words=30, prompt=''):
'''
image_... | 3,346 | 34.989247 | 114 | py |
what-is-where-by-looking | what-is-where-by-looking-main/datasets/base.py | import random
from enum import Enum
from typing import Tuple, List, Type, Iterator
import PIL
import torch.utils.data.dataset
import torch.utils.data.sampler
from PIL import Image
from torch import Tensor
from torch.nn import functional as F
from torchvision.transforms import transforms
class Base(torch.utils.data.d... | 6,834 | 42.535032 | 171 | py |
what-is-where-by-looking | what-is-where-by-looking-main/datasets/referit_loader.py | import pickle
import json
import torch
from PIL import Image
import os
import pandas as pd
from torch.utils.data.sampler import WeightedRandomSampler
import numpy as np
from datasets.tfs import get_flicker_transform
import xml.etree.ElementTree as ET
import random
from tqdm import tqdm
from utils_grounding import union... | 4,168 | 37.247706 | 106 | py |
what-is-where-by-looking | what-is-where-by-looking-main/datasets/coco2017.py | import json
import os
import pickle
import random
from typing import List, Tuple, Dict
import torch
import torch.utils.data.dataset
from PIL import Image, ImageOps
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
from torch import Tensor
from torchvision.datasets import CocoDetection
from tq... | 10,208 | 42.815451 | 159 | py |
what-is-where-by-looking | what-is-where-by-looking-main/datasets/flicker.py | import torch
from PIL import Image
import os
import pandas as pd
from torch.utils.data.sampler import WeightedRandomSampler
import numpy as np
from datasets.tfs import get_flicker_transform
import xml.etree.ElementTree as ET
import random
from tqdm import tqdm
from utils_grounding import union
from random import shuffl... | 12,634 | 38.484375 | 112 | py |
what-is-where-by-looking | what-is-where-by-looking-main/datasets/visual_genome.py | import pickle
import json
import torch
from PIL import Image
import os
import pandas as pd
from torch.utils.data.sampler import WeightedRandomSampler
import numpy as np
from datasets.tfs import get_flicker_transform
import xml.etree.ElementTree as ET
import random
from tqdm import tqdm
from utils_grounding import union... | 6,545 | 39.658385 | 120 | py |
what-is-where-by-looking | what-is-where-by-looking-main/datasets/tfs.py | import torchvision.transforms as transforms
# from utils import *
resizedict = {'224': 256,
'448': 512,
'112': 128}
def get_aircraft_transform(size=224):
return get_cub_transform(size=size)
def get_car_transform(size=224):
return get_cub_transform(size=size)
def get_dog_trans... | 3,954 | 28.962121 | 111 | py |
what-is-where-by-looking | what-is-where-by-looking-main/datasets/coco.py | import pickle
import json
import torch
from PIL import Image
import os
import pandas as pd
from torch.utils.data.sampler import WeightedRandomSampler
import numpy as np
from datasets.tfs import get_flicker_transform
import xml.etree.ElementTree as ET
import random
from tqdm import tqdm
from utils_grounding import union... | 5,908 | 40.321678 | 120 | py |
what-is-where-by-looking | what-is-where-by-looking-main/CLIP/clip/clip.py | import hashlib
import os
import urllib
import warnings
from typing import Union, List
import torch
from PIL import Image
from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
from tqdm import tqdm
from .model import build_model
from .simple_tokenizer import SimpleTokenizer as _Tokenizer
... | 7,279 | 36.525773 | 142 | py |
what-is-where-by-looking | what-is-where-by-looking-main/CLIP/clip/model.py | from collections import OrderedDict
from typing import Tuple, Union
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from .auxilary import *
class Bottleneck(nn.Module):
expansion = 4
def __init__(self, inplanes, planes, stride=1):
super().__init__()
# all... | 17,601 | 38.733634 | 178 | py |
what-is-where-by-looking | what-is-where-by-looking-main/CLIP/clip/auxilary.py | import torch
import warnings
from typing import Tuple, Optional
import torch
from torch import Tensor
from torch.nn.init import xavier_uniform_
from torch.nn.init import constant_
from torch.nn.init import xavier_normal_
from torch.nn.parameter import Parameter
from torch.nn import functional as F
# We define this fu... | 20,174 | 46.695035 | 130 | py |
icr | icr-main/src/mcr/distributions/utils.py | import numpyro
import torch
import pyro
import numpy as np
def numpyrodist_to_pyrodist(d):
if isinstance(d, numpyro.distributions.discrete.CategoricalProbs):
probs = d.probs
t_probs = torch.tensor(np.array(probs))
return pyro.distributions.Binomial(probs=t_probs)
elif isinstance(d, nump... | 895 | 32.185185 | 70 | py |
icr | icr-main/src/mcr/distributions/multivariate.py | import jax.random
import numpyro.distributions as dist
from numpyro.distributions.util import is_prng_key
import jax.numpy as jnp
from functools import partial, cache
import torch
class MultivariateIndependent(dist.Distribution):
def __init__(self, dss, validate_args=None):
self.dss = dss
for ds ... | 7,915 | 34.981818 | 127 | py |
icr | icr-main/src/mcr/causality/scms/examples.py | import jax.nn
from mcr.causality.scms import GenericSCM
from mcr.causality.dags import DirectedAcyclicGraph
import numpy as np
import numpyro
import numpyro.distributions as dist
from mcr.causality.scms.functions import *
import sys
# # EXAMPLE 1 SCM
#
# sigma_high = torch.tensor(0.5)
# sigma_medium = torch.tensor(0.... | 9,812 | 40.580508 | 120 | py |
icr | icr-main/src/mcr/causality/scms/functions.py | import jax.nn
import torch
import jax.numpy as jnp
class StructuralFunction:
def __init__(self, fnc, inv=None, transform=None, additive=False, binary=False, raw=None):
self.fnc = fnc
self.inv_fnc = inv
self.reverse_transform = transform
self.additive = additive
self.binary ... | 3,611 | 29.871795 | 103 | py |
icr | icr-main/src/mcr/causality/scms/binomialbinary.py | import torch
from torch import Tensor
from torch.distributions import Distribution, Normal
import numpy as np
import json
from mcr.causality import DirectedAcyclicGraph
from mcr.causality.scms import StructuralCausalModel
import torch.distributions as dist
import logging
logger = logging.getLogger(__name__)
class Bi... | 10,663 | 39.241509 | 106 | py |
icr | icr-main/src/mcr/causality/scms/generic.py | import collections
from mcr.causality.scms import StructuralCausalModel
from mcr.distributions.utils import numpyrodist_to_pyrodist, add_uncertainty
import jax.numpy as jnp
import numpyro
import numpyro.distributions as dist
import pyro
import torch
import jax.random as jrandom
import numpy as np
import logging
from ... | 25,639 | 44.140845 | 127 | py |
icr | icr-main/src/mcr/causality/scms/scm.py | import copy
import random
import pandas as pd
import networkx as nx
import numpy as np
import torch
from torch import Tensor
from torch.distributions import Distribution
import jax.random as jrandom
import numpyro
from mcr.causality import DirectedAcyclicGraph
import logging
logger = logging.getLogger(__name__)
cla... | 15,458 | 42.181564 | 138 | py |
icr | icr-main/src/mcr/causality/scms/sigmoidal.py | from mcr.causality.scms import BinomialBinarySCM
import torch
import numpy as np
import torch.distributions as dist
from mcr.causality.dags import DirectedAcyclicGraph
import json
import logging
from mcr.distributions.multivariate import TransformedUniform
logger = logging.getLogger()
class SigmoidBinarySCM(BinomialB... | 9,518 | 40.567686 | 108 | py |
icr | icr-main/src/mcr/recourse/utils.py | import json
import logging
import numpy as np
import pandas as pd
import torch
from mcr.causality.utils import indvd_to_intrv
def compute_h_post_individualized(scm, X_pre, X_post, invs, features, y_name, y=1):
"""
Computes the individualized post-recourse predictions (probabilities)
"""
log_probs = ... | 1,740 | 36.847826 | 93 | py |
icr | icr-main/src/mcr/recourse/evaluation.py | import numpy as np
import pandas as pd
import torch
import logging
import functools
from mcr.causality.utils import indvd_to_intrv
logger = logging.getLogger(__name__)
def similar(in1, in2, nr_digits=2):
in1_r = [round(x, nr_digits) for x in in1]
in2_r = [round(x, nr_digits) for x in in2]
return in1_r ==... | 6,106 | 40.263514 | 122 | py |
Missingness-Shift | Missingness-Shift-main/missingness.py | """Main script to run missingness shift experiments.
Example command for synthetic datasets:
python missingness.py --dataset bernoulli1 \
--num_beta_samples 1 --num_missingness_samples 20 \
--linreg --xgb --nn --tag tag_name --imputation --verbose
Example command for semi-synthetic datasets: (need to create c... | 23,000 | 39.927046 | 141 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/RegressionBaseline/eval_xgb_features.py | import os,sys
import h5py as h5
import numpy as np
import xgboost as xgb
from sklearn.model_selection import train_test_split
from sklearn.utils import shuffle
if len(sys.argv) < 2:
print 'usage: python eval_xgb_features.py <output_label>'
label = sys.argv[1]
## local laptop
basepath = '/home/olivito/datasci/lcd... | 4,688 | 44.086538 | 117 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/RegressionBaseline/train_xgb_features.py | import os,sys,glob
import h5py as h5
import numpy as np
import xgboost as xgb
from sklearn.model_selection import train_test_split
from sklearn.utils import shuffle
## local laptop
# basepath = '/home/olivito/datasci/lcd/data'
## culture-plate at caltech
#basepath = '/data/shared/LCDLargeWindow'
# input_filename = ba... | 9,200 | 44.102941 | 117 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/triforce.py | ################################################################
# ########################################################## #
# # # #
# # /\\ TRIFORCE PARTICLE IDENTIFICATION SYSTEM # #
# # /__\\ Classification, Energy Regression & GAN ... | 23,749 | 41.715827 | 241 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/ResNet.py | import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import math, pdb
from Architectures import LossFunctions
import numpy as np
##################
# Classification #
##################
CLASSIFICATION, REGRESSION = 0, 1
class ResBlock(nn.M... | 4,172 | 38 | 138 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/Discriminator.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
##################
# Discriminator #
##################
class Discriminator_Net(nn.Module):
def __init__(self, options):
super().__init__()
self.conv_1 = nn.Conv3d(1, ... | 2,017 | 31.548387 | 121 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/Combined_DNN.py | import pdb # NOQA
import math
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from Architectures import LossFunctions
from Architectures import Optimizer # NOQA
##################
# Classification #
##################
CLASSIFICATION,... | 4,946 | 47.5 | 179 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/LossFunctions.py | import torch
from torch.autograd import Variable
import torch.nn.functional as F
import numpy as np
from Loader import transforms
def weighted_mse_loss(pred, target, weights):
sqerr = (pred-target)**2
sqerr = sqerr * weights
loss = torch.mean(sqerr, dim=0)
return loss
# def linear_misclassification_... | 1,700 | 47.6 | 149 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/Generator.py | import torch
import torch.nn as nn
import torch.nn.init as init
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
#############
# Generator #
#############
class Generator_Net(nn.Module):
def __init__(self, options):
super().__init__()
self.dense_1 = ... | 1,822 | 32.145455 | 121 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/Combined_CNN.py | import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import math
import pdb # NOQA
from functools import reduce
from Architectures import LossFunctions
# helper functions for getting output sizes
def size_Conv3d(in_size, kernel_size, stride... | 6,836 | 44.885906 | 138 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/Optimizer.py | from torch.optim.optimizer import Optimizer, required
import copy
class LinearRampOptimizer(Optimizer):
""" Uses the SGD with linearly ramped learning rate, as described in
https://research.fb.com/wp-content/uploads/2017/06/imagenet1kin1h5.pdf?.
Args:
params (iterable): iterable of parameters ... | 1,678 | 38.046512 | 96 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/ResNet_ReLu.py | import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import math, pdb
from Architectures import LossFunctions
import numpy as np
##################
# Classification #
##################
CLASSIFICATION, REGRESSION = 0, 1
def conv3x3(in_plan... | 6,849 | 35.43617 | 138 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/GoogLeNet.py | import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import math
import pdb # NOQA
from Architectures import LossFunctions
##################
# Classification #
##################
epsilon = 1e-07
CLASSIFICATION, REGRESSION = 0, 1
class I... | 6,983 | 36.751351 | 123 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Combined_Classifier.py | import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import math, pdb
##################
# Classification #
##################
CLASSIFICATION, REGRESSION = 0, 1
class Classifier_Net(nn.Module):
def __init__(self, options):
sup... | 3,404 | 43.802632 | 127 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Fixed_Angle_Classifier.py | import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import math
from Architectures import LossFunctions
import pdb
##################
# Classification #
##################
class Classifier_Net(nn.Module):
def __init__(self, options): ... | 2,211 | 41.538462 | 121 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/HighEnergyClassification.py | import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import math, pdb
from Architectures import LossFunctions
##################
# Classification #
##################
CLASSIFICATION, REGRESSION = 0, 1
class Classifier_Net(nn.Module):
... | 4,264 | 44.37234 | 123 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Regression/LargerWindow_Regressor.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
##############
# Regression #
##############
class Regressor_Net(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv3d(1, 3, (4, 4, 4))
self.conv2 = nn.Conv3d(1, 10, (2, 2, 6)... | 1,456 | 31.377778 | 99 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Regression/DNNRegressor.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
##############
# Regression #
##############
class Regressor_Net(nn.Module):
def __init__(self, hiddenLayerNeurons, nHiddenLayers, dropoutProb):
super().__init__()
self.input = nn.Linear(51 * 51 * 25 + 1... | 1,267 | 36.294118 | 99 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Regression/NIPS_Regressor.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
##############
# Regression #
##############
class Regressor_Net(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv3d(1, 3, (4, 4, 4))
self.conv2 = nn.Conv3d(1, 10, (2, 2, 6)... | 1,453 | 31.311111 | 99 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/GAN/NIPS_GAN.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
#######
# GAN #
#######
class Truth_Identification_Net(nn.Module):
def __init__(self, hiddenLayerNeurons, nHiddenLayers, dropoutProb):
super().__init__()
self.input = nn.Linear(25 * 25 * 25, hiddenLayerN... | 1,197 | 35.30303 | 99 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Classification/ResNet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
##################
# Classification #
##################
class ResBlock(nn.Module):
def __init__(self, NumChannels):
super().__init__()
self.conv0 = nn.Conv3d(NumChannels, NumChannels, 3, stride=1, padd... | 2,438 | 31.092105 | 99 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Classification/NIPS_Classifier.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
##################
# Classification #
##################
class Classifier_Net(nn.Module):
def __init__(self, hasHCAL, hiddenLayerNeurons, nHiddenLayers, dropoutProb):
super().__init__()
self.hasHCAL = ha... | 1,541 | 35.714286 | 105 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Classification/Variable_Angle_Classifier.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
##################
# Classification #
##################
class Classifier_Net(nn.Module):
def __init__(self, hiddenLayerNeurons, nHiddenLayers, dropoutProb):
super().__init__()
self.input = nn.Linear(51 ... | 1,444 | 38.054054 | 99 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Classification/Fixed_Angle_Classifier.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import math
##################
# Classification #
##################
class Classifier_Net(nn.Module):
def __init__(self, hiddenLayerNeurons, nHiddenLayers, dropoutProb, windowSize):
super().__init__()
se... | 1,764 | 40.046512 | 108 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Architectures/OldArchitectures/Classification/GoogLeNet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import pdb
##################
# Classification #
##################
epsilon = 1e-07
class Inception(nn.Module):
def __init__(self, in_planes, n1x1, n3x3red, n3x3, n5x5red, n5x5, pool_planes):
super(Inception, s... | 4,158 | 31.492188 | 99 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Loader/test_loader.py | import glob
import torch.utils.data as data
from timeit import default_timer as timer
from . import blunt_loader as loader
#################################
# Load files and set up loaders #
#################################
base_path = "/public/data/calo/RandomAngle/CLIC/"
sample_path = [base_path + "Gamma/*.h5", ba... | 2,428 | 29.3625 | 143 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Loader/blunt_loader.py | import sys
import h5py as h5
import numpy as np
import torch.utils.data as data
# from Loader.filters import does_event_pass_filters
class HDF5Dataset(data.Dataset):
'''Creates a dataset from a set of H5 files. Used to create PyTorch DataLoader.'''
def __init__(self, filename_tuples, pdgIDs, filters=[]):
... | 3,151 | 39.410256 | 146 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Loader/loader.py | # HDF5Dataset is of class torch.utils.data.Dataset, and is initialized with a set of data files and the number of events per file.
# __len__ returns the number of items in the dataset, which is simply the number of files times the number of events per file.
# __getitem__ takes an index and returns that event. First it ... | 6,785 | 41.679245 | 287 | py |
Triforce_CaloML | Triforce_CaloML-master/Training/TriForce/Loader/transforms.py | import torch
from torch.autograd import Variable
# returns reg_energy, target_energy for MSE loss function (on gpu)
def reg_target_energy_for_loss(output, data):
truth_energy = Variable(data['energy'].cuda())
reco_energy = Variable((data['ECAL_E'] + data['HCAL_E']).cuda())
denom = torch.log(truth_energy)
... | 1,296 | 33.131579 | 82 | py |
TCGL | TCGL-main/2_ft_tcg_classify_sthv2.py | """Finetune 3D CNN."""
import os
import argparse
import time
import random
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.optim as optim
from tensorboardX import SummaryWriter
from datasets... | 11,235 | 44.861224 | 154 | py |
TCGL | TCGL-main/1_train_TCGL_UCF101_R3D.py | """Video clip order prediction."""
import os
import math
import itertools
import argparse
import time
import random
import logging
import sys
import pandas as pd
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.op... | 18,459 | 47.198433 | 192 | py |
TCGL | TCGL-main/1_train_TCGL_K400_R21D.py | """Video clip order prediction."""
import os
import math
import itertools
import argparse
import time
import random
import logging
import sys
import pandas as pd
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.op... | 18,299 | 47.28496 | 192 | py |
TCGL | TCGL-main/2_ft_tcg_classify.py | """Finetune 3D CNN."""
import os
import argparse
import time
import random
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.optim as optim
from tensorboardX import SummaryWriter
from datasets... | 10,789 | 44.146444 | 151 | py |
TCGL | TCGL-main/1_train_TCGL_UCF101_R21D.py | """Video clip order prediction."""
import os
import math
import itertools
import argparse
import time
import random
import logging
import sys
import pandas as pd
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.op... | 18,288 | 47.128947 | 192 | py |
TCGL | TCGL-main/2_ft_tcg_classify_K400.py | """Finetune 3D CNN."""
import os
import argparse
import time
import random
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.optim as optim
from tensorboardX import SummaryWriter
from datasets... | 10,736 | 43.924686 | 149 | py |
TCGL | TCGL-main/eval_svm_feature_extract_k400.py | """Train 3D ConvNets to action classification."""
import os
import argparse
import time
import random
import numpy as np
#import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.optim as optim
#from tensorboardX import... | 15,553 | 43.567335 | 149 | py |
TCGL | TCGL-main/3_train_classify_sthv2.py | """Train 3D ConvNets to action classification."""
import os
import argparse
import time
import random
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.optim as optim
from tensorboardX import S... | 15,435 | 44.533923 | 141 | py |
TCGL | TCGL-main/3_train_classify_K400.py | """Train 3D ConvNets to action classification."""
import os
import argparse
import time
import random
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.optim as optim
from tensorboardX import S... | 13,390 | 42.477273 | 146 | py |
TCGL | TCGL-main/4_retrieve_clips.py | """Video retrieval experiment, top-k."""
import os
import math
import itertools
import argparse
import time
import random
import json
from tqdm import tqdm
import pandas as pd
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
... | 8,056 | 39.285 | 138 | py |
TCGL | TCGL-main/1_train_TCGL_K400_R3D.py | """Video clip order prediction."""
import os
import math
import itertools
import argparse
import time
import random
import logging
import sys
import pandas as pd
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.op... | 18,381 | 47.373684 | 192 | py |
TCGL | TCGL-main/1_train_TCGL_UCF101_C3D.py | """Video clip order prediction."""
import os
import math
import itertools
import argparse
import time
import random
import logging
import sys
import pandas as pd
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.op... | 17,468 | 47.123967 | 192 | py |
TCGL | TCGL-main/1_train_TCGL_UCF101_R3D50.py | """Video clip order prediction."""
import os
import math
import itertools
import argparse
import time
import random
import logging
import sys
import pandas as pd
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.op... | 18,420 | 47.222513 | 192 | py |
TCGL | TCGL-main/3_train_classify.py | """Train 3D ConvNets to action classification."""
import os
import argparse
import time
import random
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.optim as optim
from tensorboardX import S... | 12,868 | 41.896667 | 155 | py |
TCGL | TCGL-main/1_train_TCGL_K400_C3D.py | """Video clip order prediction."""
import os
import math
import itertools
import argparse
import time
import random
import logging
import sys
import pandas as pd
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.op... | 18,314 | 47.197368 | 192 | py |
TCGL | TCGL-main/eval_svm_feature_extractv2.py | """Train 3D ConvNets to action classification."""
import os
import argparse
import time
import random
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, random_split
from torchvision import transforms
import torch.optim as optim
from tensorboardX import S... | 14,680 | 45.021944 | 155 | py |
TCGL | TCGL-main/models/r2d3d.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import math
__all__ = [
'ResNet2d3d', 'r2d3d50', 'r3d50'
]
def conv3x3x3(in_planes, out_planes, stride=1, bias=False):
# 3x3x3 convolution with padding
return nn.Conv3d(
in_planes,
out_pl... | 9,126 | 31.480427 | 121 | py |
TCGL | TCGL-main/models/r3d_50.py | import math
from functools import partial
import torch
import torch.nn as nn
import torch.nn.functional as F
def get_inplanes():
return [64, 128, 256, 512]
def conv3x3x3(in_planes, out_planes, stride=1):
return nn.Conv3d(in_planes,
out_planes,
kernel_size=3,
... | 8,838 | 32.481061 | 95 | py |
TCGL | TCGL-main/models/TCG.py | """TCG"""
import math
from collections import OrderedDict
import random
import torch
import torch.nn as nn
from torch.nn.modules.utils import _triple
from torch_geometric.nn import GCNConv
from torch_geometric.nn import GATConv
from torch_geometric.utils import dropout_adj
import torch.nn.functional as F
import numpy a... | 215,297 | 45.93656 | 328 | py |
TCGL | TCGL-main/models/s3d_g.py | import torch
import torch.nn as nn
from collections import OrderedDict
from models.i3d import Flatten, Normalize
# import ipdb
import torch.nn.functional as F
class BasicConv3d(nn.Module):
def __init__(self,
in_channel,
out_channel,
kernel_size=1,
... | 7,928 | 43.544944 | 123 | py |
TCGL | TCGL-main/models/c3d.py | """C3D"""
import math
from collections import OrderedDict
import torch
import torch.nn as nn
from torch.nn.modules.utils import _triple
class C3D(nn.Module):
"""C3D with BN and pool5 to be AdaptiveAvgPool3d(1)."""
def __init__(self, with_classifier=False, return_conv=False, num_classes=101):
super(C3... | 3,454 | 30.697248 | 94 | py |
TCGL | TCGL-main/models/xcorr2.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class xcorr2(nn.Module):
'''
Correlates two images. Images must be of the same size.
'''
def __init__(self, zero_mean_normalize=True):
super(xcorr2, self).__init__()
#self.InstanceNorm =... | 3,405 | 34.852632 | 100 | py |
TCGL | TCGL-main/models/fca_layer.py | import torch,math
import torch.nn.functional as F
def get_1d_dct(i, freq, L):
result = math.cos(math.pi * freq * (i + 0.5) / L) / math.sqrt(L)
if freq == 0:
return result
else:
return result * math.sqrt(2)
def get_dct_weights( width, height, channel, fidx_u= [0,0,6,0,0,1,1,4,5,1,3,0,0,0... | 2,377 | 40.719298 | 131 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.