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 |
|---|---|---|---|---|---|---|
GSRFormer | GSRFormer-main/inference.py | # ----------------------------------------------------------------------------------------------
# CoFormer Official Code
# Copyright (c) Junhyeong Cho. All Rights Reserved
# Licensed under the Apache License 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------... | 11,245 | 41.437736 | 160 | py |
GSRFormer | GSRFormer-main/main.py | # ----------------------------------------------------------------------------------------------
# CoFormer Official Code
# Copyright (c) Junhyeong Cho. All Rights Reserved
# Licensed under the Apache License 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------... | 22,194 | 52.871359 | 138 | py |
GSRFormer | GSRFormer-main/engine.py | import os
import sys
import math
import json
import torch
from torch import nn
import util.misc as utils
from typing import Iterable
def encoder_train_one_epoch(model: torch.nn.Module, criterion: torch.nn.Module,
data_loader: Iterable, optimizer: torch.optim.Optimizer,
... | 12,049 | 43.464945 | 115 | py |
GSRFormer | GSRFormer-main/models/gsrformer.py | import torch
import torch.nn.functional as F
from torch import nn
from util import box_ops
from util.misc import (NestedTensor, nested_tensor_from_tensor_list,
accuracy, accuracy_swig, accuracy_swig_bbox)
from .backbone import build_backbone
from .transformer import build_encoder_encoder as build... | 33,410 | 50.719814 | 163 | py |
GSRFormer | GSRFormer-main/models/position_encoding.py | # ----------------------------------------------------------------------------------------------
# CoFormer Official Code
# Copyright (c) Junhyeong Cho. All Rights Reserved
# Licensed under the Apache License 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------... | 3,844 | 38.639175 | 103 | py |
GSRFormer | GSRFormer-main/models/backbone.py | # ----------------------------------------------------------------------------------------------
# CoFormer Official Code
# Copyright (c) Junhyeong Cho. All Rights Reserved
# Licensed under the Apache License 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------... | 3,805 | 39.063158 | 133 | py |
GSRFormer | GSRFormer-main/models/transformer.py | import copy
import torch.nn.functional as F
from tkinter import N
from turtle import forward
from typing import Optional
import torch
from torch import nn, Tensor
class Encoder_Transformer_Encoder(nn.Module):
def __init__(self, dim_model=512, nhead=8, num_enc_layers=6, dim_feedforward=2048, dropout=0.15, activation... | 15,854 | 44.429799 | 127 | py |
GSRFormer | GSRFormer-main/util/misc.py | # -----------------------------------------------------------------------------------------------------
# CoFormer Official Code
# Copyright (c) Junhyeong Cho. All Rights Reserved
# Licensed under the Apache License 2.0 [see LICENSE for details]
# -----------------------------------------------------------------------... | 18,051 | 32.742056 | 140 | py |
GSRFormer | GSRFormer-main/util/box_ops.py | # ----------------------------------------------------------------------------------------------
# CoFormer Official Code
# Copyright (c) Junhyeong Cho. All Rights Reserved
# Licensed under the Apache License 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------... | 4,196 | 34.268908 | 97 | py |
GSRFormer | GSRFormer-main/datasets/swig.py | # -----------------------------------------------------------------------------------------------------
# CoFormer Official Code
# Copyright (c) Junhyeong Cho. All Rights Reserved
# Licensed under the Apache License 2.0 [see LICENSE for details]
# -----------------------------------------------------------------------... | 27,261 | 37.182073 | 240 | py |
gaminet | gaminet-master/gaminet/layers.py | import numpy as np
import tensorflow as tf
import tensorflow_lattice as tfl
from tensorflow.keras import layers
class CategNet(tf.keras.layers.Layer):
def __init__(self, category_num, cagetnet_id):
super(CategNet, self).__init__()
self.category_num = category_num
self.cagetnet_id = cagetn... | 33,367 | 51.465409 | 120 | py |
gaminet | gaminet-master/gaminet/gaminet.py | import numpy as np
import os
import pickle
import tensorflow as tf
from sklearn.model_selection import train_test_split
from .layers import *
from .utils import get_interaction_list
class GAMINet(tf.keras.Model):
def __init__(self, meta_info,
interact_num=20,
subnet_arch=[40] *... | 58,148 | 56.573267 | 139 | py |
attention-iclr | attention-iclr-master/attention/experiments/vgg16_testing.py | """
Test a pretrained VGG16 on ImageNet.
"""
gpu = input('GPU: ')
data_partition = input('Data partition in {train, val, val_white}: ')
import os
os.environ['CUDA_DEVICE_ORDER'] = 'PCI_BUS_ID'
os.environ['CUDA_VISIBLE_DEVICES'] = gpu
import numpy as np
import pandas as pd
import tensorflow as tf
from ..utils.paths i... | 690 | 29.043478 | 73 | py |
attention-iclr | attention-iclr-master/attention/experiments/representations.py | """
For each ImageNet category, take the VGG16 representations of images
belonging to it, and compute the mean of these. The VGG16 representation of an
image is found by computing a forward pass through the network and looking at
the activation of the penultimate layer.
"""
import os
os.environ['CUDA_DEVICE_ORDER'] = ... | 1,655 | 32.12 | 78 | py |
attention-iclr | attention-iclr-master/attention/utils/training.py | """
Train a model using either `flow_from_directory` or `flow_from_dataframe`.
"""
import numpy as np
import pandas as pd
import tensorflow as tf
from ..utils.metadata import wnids
from ..utils.paths import path_repo
def parameters_training(split=0.1):
datagen_training = tf.keras.preprocessing.image.ImageDataGene... | 3,026 | 34.611765 | 80 | py |
attention-iclr | attention-iclr-master/attention/utils/testing.py | """
Test a model, or compute its predictions, using either `flow_from_directory` or
`flow_from_dataframe`.
"""
import numpy as np
import pandas as pd
import tensorflow as tf
from ..utils.metadata import wnids
def parameters_testing():
datagen_testing = tf.keras.preprocessing.image.ImageDataGenerator(
prep... | 3,195 | 34.910112 | 80 | py |
attention-iclr | attention-iclr-master/attention/utils/layers.py | """
Multiply each element of an input tensor by a separate attention weight.
References:
- stackoverflow.com/questions/46821845/how-to-add-a-trainable-hadamard-product-layer-in-keras
- keras.io/layers/writing-your-own-keras-layers
- tensorflow.org/guide/keras/custom_layers_and_models
"""
import tensorflow as tf
clas... | 933 | 31.206897 | 93 | py |
attention-iclr | attention-iclr-master/attention/utils/models.py | """
Take a pretrained VGG16, fix its weights and insert an attention layer.
"""
import tensorflow as tf
def attention_network(attention_layer, position='block5_pool'):
vgg = tf.keras.applications.VGG16()
model = tf.keras.models.Sequential()
for layer in vgg.layers:
layer.trainable = False
... | 601 | 29.1 | 71 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/train_multiwoz.py | #!/bin/env python
import os
import shutil
import logging
import torch
import wandb
import nltk
from train import Trainer, parse_args, setup_logging # noqa:E402
from generate import generate_predictions # noqa:E402
from data.evaluation.multiwoz import MultiWozEvaluator, compute_bmr_remove_reference, compute_delexical... | 5,514 | 44.578512 | 125 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/evaluate_convlab.py | #!/bin/env python
import os
import argparse
import logging
import torch
import transformers
from utils import setup_logging, pull_model # noqa:E402
import data.evaluation.multiwoz.convlab # noqa: E402
import nltk
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--model', de... | 1,503 | 28.490196 | 119 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/generate.py | #!/bin/env python
import logging
import torch
import argparse
import dataclasses
import itertools
from collections import OrderedDict
from data.utils import DialogDatasetItem
from data.utils import BeliefParser, InsertLabelsTransformation, format_belief, format_database
from utils import pull_model, setup_logging
from ... | 5,013 | 39.764228 | 107 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/hubconf.py | dependencies = ['torch', 'transformers', 'fuzzywuzzy']
import pipelines # noqa
import transformers # noqa
from model import ModelPredictor # noqa
def augpt_conversational_pipeline(model='jkulhanek/augpt-mw-21', **kwargs):
"""
Loads the AuGPT conversational pipeline, which could be used as a dialogue system... | 2,127 | 41.56 | 108 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/pipelines.py | from typing import Union, List, Optional
import logging
import uuid
from uuid import UUID
import transformers
from functools import partial
from collections import OrderedDict
from model import ModelPredictor
from data import BeliefParser
from utils import AutoDatabase, AutoLexicalizer, AutoDocbase
logger = logging.g... | 16,052 | 44.092697 | 130 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/utils.py | import os
import sys
import types
import shutil
import logging
import requests
import torch
import transformers
import zipfile
import json
from collections import OrderedDict
from data.utils import Documentbase
# We will fix transformers remote url resolution for older transformer versions
def _fix_transformers_url():... | 17,614 | 36.88172 | 151 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/model.py | import dataclasses
import logging
from dataclasses import dataclass
from transformers import GPT2Tokenizer as AuGPTTokenizer # noqa
from torch import nn
import transformers
from torch.nn import functional as F
import torch
import data
EOB_TK = '<|eob|>'
EOKB_TK = '<|eokb|>'
EOD_TK = '<|eod|>'
EOT_TK = '<|endoftext|>... | 16,720 | 44.685792 | 170 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/evaluate_multiwoz.py | #!/bin/env python
import os
import argparse
import logging
import torch
import transformers
import nltk
from collections import OrderedDict
from utils import setup_logging, pull_model # noqa:E402
from data.utils import BeliefParser, DatabaseParser, wrap_dataset_with_cache # noqa: E402
from data import load_dataset ... | 5,120 | 40.634146 | 136 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/train.py | #!/bin/env python
import sys
import logging
import os
import argparse
import transformers
import torch
from torch.nn.parallel import DistributedDataParallel
from torchvision.transforms import Compose as ComposeTransformation
import tensorboardX
from tqdm import tqdm
import wandb
from pipelines import AuGPTConversationa... | 23,964 | 45.898239 | 120 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/tests/test_train.py | import dataclasses
import tempfile
import pytest
@pytest.fixture()
def logger():
import logging
return logging.getLogger()
def patch_dataset(dataset):
return dataclasses.replace(dataset, items=[dataset[i] for i in range(2)], transform=lambda x: x)
@pytest.mark.train
def test_train(logger, monkeypatch)... | 3,409 | 41.098765 | 115 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/data/negative_sampling.py | import torch
import random
import dataclasses
from collections import OrderedDict
from .utils import format_belief
class NegativeSamplingDatasetWrapper(torch.utils.data.Dataset):
def __init__(self, inner, transform=None):
self.inner = inner
self.transform = transform
assert hasattr(self.in... | 2,949 | 34.97561 | 103 | py |
SeKnow | SeKnow-main/SeKnow-PLM/scripts/data/utils.py | import re
import random
import copy
import logging
from fuzzywuzzy import fuzz
from typing import Callable, Union, Set, Optional, List, Dict, Any, Tuple, MutableMapping # noqa: 401
import dataclasses
from collections import OrderedDict, defaultdict
from dataclasses import dataclass
import torch
from torch.nn.utils.rnn... | 17,486 | 36.850649 | 120 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Multiple/copy_modules.py | import torch
import torch.nn.functional as F
from torch import nn
from config import global_config as cfg
from modules import *
def get_selective_read(source, target, hiddens, copy_probs):
cp_pos = torch.stack([sb==target[b] for b, sb in enumerate(source)], dim=0) # [B,T]
weight = copy_probs * cp_pos.... | 32,001 | 46.131075 | 119 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Multiple/base_model.py | import torch
from torch import nn
from utils import BeamState, toss_, padSeqs
from copy_modules import *
class BaseModel(nn.Module):
def __init__(self, cfg, reader, has_qnet):
super().__init__()
self.cfg = cfg
self.hidden_size = cfg.hidden_size
self.vocab_size = cfg.vocab_size
... | 37,179 | 50.78273 | 140 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Multiple/smc_model.py | import torch
from torch import nn
from torch.distributions import Categorical
import numpy as np
from config import global_config as cfg
from modules import get_one_hot_input, cuda_
from base_model import BaseModel
from utils import toss_
torch.set_printoptions(sci_mode=False)
class SemiBootstrapSMC(BaseModel):
... | 13,276 | 51.478261 | 118 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Multiple/rnn_net.py | import torch
from torch import nn
import torch.nn.functional as F
import numpy as np
import math
from config import global_config as cfg
def cuda_(var, aux=None):
if not aux:
return var.cuda() if cfg.cuda else var
elif aux != 'cpu' and aux >= 0 and cfg.cuda:
return var.cuda(aux)
else:
... | 5,147 | 38.6 | 111 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Multiple/common_layer.py | ### MOSTO OF IT TAKEN FROM https://github.com/kolloldas/torchnlp
## MINOR CHANGES
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.nn.init as I
import numpy as np
import math
class EncoderLayer(nn.Module):
"""
Represents one Encoder layer of t... | 19,354 | 38.259635 | 116 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Multiple/modules.py | import torch
from torch import nn
import torch.nn.functional as F
from torch.autograd import Variable
from UTransformer import *
import numpy as np
from config import global_config as cfg
def cuda_(var):
return var.cuda() if cfg.cuda else var
def get_one_hot_input(input_t, v_dim=None):
"""
word index se... | 9,274 | 38.978448 | 125 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Multiple/UTransformer.py | ### TAKEN FROM https://github.com/kolloldas/torchnlp
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.nn.init as I
import numpy as np
import math
from common_layer import EncoderLayer, DecoderLayer, LayerNorm, LayerNorm_No_Grad, _gen_bias_mask, _gen_ti... | 12,426 | 42.299652 | 156 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Multiple/train.py | import logging, time, os, json, random, argparse
import numpy as np
import torch
import math
import utils
from config import global_config as cfg
from reader import CamRest676Reader, MultiwozReader, KvretReader
from vae_model import SemiCVAE
from smc_model import SemiBootstrapSMC
# from cjsa_model import SemiNASMC
# f... | 30,122 | 52.126984 | 196 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Multiple/vae_model.py | import numpy as np
import torch
from torch import nn
from config import global_config as cfg
from modules import get_one_hot_input, cuda_
from base_model import BaseModel
from metric import BLEUScorer
class MultinomialKLDivergenceLoss(nn.Module):
def __init__(self):
super().__init__()
def forward(sel... | 14,407 | 49.027778 | 121 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Single/copy_modules.py | import torch
import torch.nn.functional as F
from torch import nn
from config import global_config as cfg
from modules import *
def get_selective_read(source, target, hiddens, copy_probs):
cp_pos = torch.stack([sb==target[b] for b, sb in enumerate(source)], dim=0) # [B,T]
weight = copy_probs * cp_pos... | 32,246 | 46.4919 | 119 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Single/base_model.py | import torch
from torch import nn
from utils import BeamState, toss_, padSeqs
from copy_modules import *
class BaseModel(nn.Module):
def __init__(self, cfg, reader, has_qnet):
super().__init__()
self.cfg = cfg
self.hidden_size = cfg.hidden_size
self.vocab_size = cfg.vocab_size
... | 37,896 | 49.462051 | 140 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Single/smc_model.py | import torch
from torch import nn
from torch.distributions import Categorical
import numpy as np
from config import global_config as cfg
from modules import get_one_hot_input, cuda_
from base_model import BaseModel
from utils import toss_
torch.set_printoptions(sci_mode=False)
class SemiBootstrapSMC(BaseModel):
... | 13,111 | 51.448 | 118 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Single/rnn_net.py | import torch
from torch import nn
import torch.nn.functional as F
import numpy as np
import math
from config import global_config as cfg
def cuda_(var, aux=None):
if not aux:
return var.cuda() if cfg.cuda else var
elif aux != 'cpu' and aux >= 0 and cfg.cuda:
return var.cuda(aux)
else:
... | 5,147 | 38.6 | 111 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Single/common_layer.py | ### MOSTO OF IT TAKEN FROM https://github.com/kolloldas/torchnlp
## MINOR CHANGES
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.nn.init as I
import numpy as np
import math
class EncoderLayer(nn.Module):
"""
Represents one Encoder layer of t... | 19,355 | 38.182186 | 116 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Single/modules.py | import torch
from torch import nn
import torch.nn.functional as F
from torch.autograd import Variable
from UTransformer import *
import numpy as np
from config import global_config as cfg
import math
def cuda_(var):
return var.cuda() if cfg.cuda else var
def get_one_hot_input(input_t, v_dim=None):
"""
w... | 9,466 | 39.457265 | 125 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Single/UTransformer.py | ### TAKEN FROM https://github.com/kolloldas/torchnlp
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.nn.init as I
import numpy as np
import math
from common_layer import EncoderLayer, DecoderLayer, LayerNorm, LayerNorm_No_Grad, _gen_bias_mask, _gen_ti... | 12,426 | 42.299652 | 156 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Single/train.py | import logging, time, os, json, random, argparse
import numpy as np
import torch
import math
import utils
from config import global_config as cfg
from reader import CamRest676Reader, MultiwozReader, KvretReader
from vae_model import SemiCVAE
from smc_model import SemiBootstrapSMC
# from cjsa_model import SemiNASMC
# f... | 30,122 | 52.126984 | 196 | py |
SeKnow | SeKnow-main/SeKnow-S2S/Single/vae_model.py | import numpy as np
import torch
from torch import nn
from config import global_config as cfg
from modules import get_one_hot_input, cuda_
from base_model import BaseModel
from metric import BLEUScorer
class MultinomialKLDivergenceLoss(nn.Module):
def __init__(self):
super().__init__()
def forward(sel... | 14,407 | 49.027778 | 121 | py |
fennel | fennel-master/setup.py | #!/usr/bin/env python
import pathlib
from setuptools import setup
# Parent directory
HERE = pathlib.Path(__file__).parent
# The readme file
README = (HERE / "README.md").read_text()
setup(
name="fennel_seed",
version="1.3.4",
description="Light-yields for tracks, and cascades",
long_description=READ... | 898 | 23.297297 | 71 | py |
fennel | fennel-master/fennel/hadron_cascades.py | # -*- coding: utf-8 -*-
# Name: hadron_cascades.py
# Authors: Stephan Meighen-Berger
# Constructs a hadron cascade, defined by the emitted photons
import logging
import numpy as np
from scipy.special import gamma as gamma_func
from scipy.interpolate import UnivariateSpline
import pickle
import pkgutil
from .config imp... | 23,517 | 30.026385 | 79 | py |
fennel | fennel-master/fennel/tracks.py | # -*- coding: utf-8 -*-
# Name: tracks.py
# Authors: Stephan Meighen-Berger
# Constructs a track, defined by the emission of photons
import logging
import numpy as np
import pickle
import pkgutil
from .config import config
# Checking if jax should be used
try:
import jax.numpy as jnp
except ImportError:
if con... | 8,249 | 27.645833 | 79 | py |
fennel | fennel-master/fennel/config.py | # -*- coding: utf-8 -*-
# Name: config.py
# Authors: Stephan Meighen-Berger
# Config file for the fennel package.
import logging
from typing import Dict, Any
import yaml
import numpy as np
_baseconfig: Dict[str, Any]
_baseconfig = {
###########################################################################
... | 13,795 | 29.5898 | 79 | py |
fennel | fennel-master/fennel/em_cascades.py | # -*- coding: utf-8 -*-
# Name: em_cascades.py
# Authors: Stephan Meighen-Berger
# Constructs an electromagnetic cascade, defined by the emitted photons
import logging
import numpy as np
import pickle
import pkgutil
from scipy.special import gamma as gamma_func
from .config import config
try:
import jax.numpy as j... | 11,742 | 27.711491 | 79 | py |
fennel | fennel-master/fennel/photons.py | # -*- coding: utf-8 -*-
# Name: photons.py
# Authors: Stephan Meighen-Berger
# Calculates the number of photons depending on the track length
import logging
import numpy as np
from .config import config
from .tracks import Track
from .em_cascades import EM_Cascade
from .hadron_cascades import Hadron_Cascade
try:
i... | 40,053 | 36.468662 | 79 | py |
fennel | fennel-master/fennel/fennel.py | # -*- coding: utf-8 -*-
# Name: fennel.py
# Authors: Stephan Meighen-Berger
# Main interface to the fennel model. Calculates the light yields using the
# Aachen parametrization from
# https://www.institut3b.physik.rwth-aachen.de/global/show_document.asp?id=aaaaaaaaaapwhjz
# which is Leif Raedel's Master thesis
# Impor... | 20,256 | 39.35259 | 90 | py |
nestle | nestle-master/docs/conf.py | # -*- coding: utf-8 -*-
#
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys... | 8,987 | 30.536842 | 79 | py |
gradcam.pytorch | gradcam.pytorch-master/3_detector/inference_bbox.py | import os
import cv2
import sys
import numpy as np
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
import torchvision
import argparse
import config as cf
import operator
import csv
from torchvision import datasets, models, transforms
from networks import *
from torch.autograd import Variable
f... | 6,337 | 36.72619 | 118 | py |
gradcam.pytorch | gradcam.pytorch-master/3_detector/misc_functions.py | # ************************************************************
# Author : Bumsoo Kim, 2017
# Github : https://github.com/meliketoy/cellnet.pytorch
#
# Korea University, Data-Mining Lab
# Deep Convolutional Network Grad CAM Implementation
#
# Description : misc_function.py
# The main code for grad-CAM image localization... | 4,056 | 28.830882 | 79 | py |
gradcam.pytorch | gradcam.pytorch-master/3_detector/baseline_prediction.py | import os
import cv2
import sys
import numpy as np
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
import torchvision
import argparse
import config as cf
import operator
import csv
from torchvision import datasets, models, transforms
from networks import *
from torch.autograd import Variable
f... | 4,209 | 30.654135 | 111 | py |
gradcam.pytorch | gradcam.pytorch-master/3_detector/launch_model.py | # ************************************************************
# Author : Bumsoo Kim, 2017
# Github : https://github.com/meliketoy/cellnet.pytorch
#
# Korea University, Data-Mining Lab
# Deep Convolutional Network Grad CAM Implementation
#
# Description : launch_model.py
# The main code for grad-CAM image localization.... | 5,798 | 29.046632 | 111 | py |
gradcam.pytorch | gradcam.pytorch-master/3_detector/detect_object.py | # ************************************************************
# Author : Bumsoo Kim, 2017
# Github : https://github.com/meliketoy/cellnet.pytorch
#
# Korea University, Data-Mining Lab
# Deep Convolutional Network Grad CAM Implementation
#
# Description : detect_cell.py
# The main code for grad-CAM image localization.
... | 8,016 | 34.473451 | 128 | py |
gradcam.pytorch | gradcam.pytorch-master/3_detector/grad_cam.py | #!/usr/bin/env python
# coding: utf-8
#
# Author: Kazuto Nakashima
# URL: http://kazuto1011.github.io
# Created: 2017-05-26
from __future__ import print_function
from collections import OrderedDict
import cv2
import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Variable
from torch... | 4,877 | 31.092105 | 74 | py |
gradcam.pytorch | gradcam.pytorch-master/3_detector/networks/resnet.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
__all__ = ['ResNet', 'resnet']
model_urls = {
'resnet18': 'http://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'http://download.pytorch.org/models/resnet34-333f7ec4.pth',
'resnet50': 'http://download.pytorch.or... | 5,733 | 31.39548 | 93 | py |
gradcam.pytorch | gradcam.pytorch-master/2_classifier/inference.py | # ************************************************************
# Author : Bumsoo Kim, 2018
# Github : https://github.com/meliketoy/gradcam.pytorch
#
# Korea University, Data-Mining Lab
# Deep Convolutional Network Fine tuning Implementation
#
# Description : inference.py
# The main code for inference test phase of trai... | 4,740 | 31.923611 | 116 | py |
gradcam.pytorch | gradcam.pytorch-master/2_classifier/main.py | # ************************************************************
# Author : Bumsoo Kim, 2018
# Github : https://github.com/meliketoy/gradcam.pytorch
#
# Korea University, Data-Mining Lab
# Deep Convolutional Network Fine tuning Implementation
#
# Description : main.py
# The main code for training classification networks.... | 11,216 | 36.265781 | 122 | py |
gradcam.pytorch | gradcam.pytorch-master/2_classifier/networks/resnet.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
__all__ = ['ResNet', 'resnet']
model_urls = {
'resnet18': 'http://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'http://download.pytorch.org/models/resnet34-333f7ec4.pth',
'resnet50': 'http://download.pytorch.or... | 5,733 | 31.39548 | 93 | py |
gradcam.pytorch | gradcam.pytorch-master/1_preprocessor/main.py | # ************************************************************
# Author : Bumsoo Kim, 2017
# Github : https://github.com/meliketoy/cellnet.pytorch
#
# Korea University, Data-Mining Lab
# Deep Convolutional Network Preprocessing Implementation
#
# Module : 1_preprocessor
# Description : main.py
# The main code for data ... | 4,540 | 40.66055 | 85 | py |
gradcam.pytorch | gradcam.pytorch-master/1_preprocessor/augmentation.py | # ************************************************************
# Author : Bumsoo Kim, 2017
# Github : https://github.com/meliketoy/cellnet.pytorch
#
# Korea University, Data-Mining Lab
# Deep Convolutional Network Preprocessing Implementation
#
# Module : 1_preprocessor
# Description : augmentation.py
# The code for im... | 2,223 | 32.19403 | 145 | py |
gradcam.pytorch | gradcam.pytorch-master/1_preprocessor/file_function.py | # ************************************************************
# Author : Bumsoo Kim, 2017
# Github : https://github.com/meliketoy/cellnet.pytorch
#
# Korea University, Data-Mining Lab
# Deep Convolutional Network Preprocessing Implementation
#
# Module : 1_preprocessor
# Description : file_function.py
# The function c... | 8,099 | 36.155963 | 123 | py |
View-Parsing-Network | View-Parsing-Network-master/test_carla.py | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# File : test.py
# Author : Bowen Pan
# Email : panbowen0607@gmail.com
# Date : 09/25/2018
#
# Distributed under terms of the MIT license.
"""
"""
from utils import Foo
from models import VPNModel
from datasets import OVMDataset
from opts import parser
from transfo... | 10,225 | 36.457875 | 191 | py |
View-Parsing-Network | View-Parsing-Network-master/test.py | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# File : test.py
# Author : Bowen Pan
# Email : panbowen0607@gmail.com
# Date : 09/25/2018
#
# Distributed under terms of the MIT license.
"""
"""
from utils import Foo
from models import VPNModel
from datasets import OVMDataset
from opts import parser
from transfo... | 9,463 | 36.113725 | 191 | py |
View-Parsing-Network | View-Parsing-Network-master/transform.py | import torchvision
import random
from PIL import Image, ImageOps
import numpy as np
import numbers
import math
import torch
class GroupRandomCrop(object):
def __init__(self, size):
if isinstance(size, numbers.Number):
self.size = (int(size), int(size))
else:
self.size = siz... | 10,960 | 32.934985 | 116 | py |
View-Parsing-Network | View-Parsing-Network-master/utils.py | import numpy as np, os, time
from six.moves import xrange
import logging
import torch
from torch.autograd import Variable
class Foo(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def __str__(self):
str_ = ''
for v in vars(self).keys():
a = getattr(self, v)
str__ = str(a... | 5,807 | 35.993631 | 122 | py |
View-Parsing-Network | View-Parsing-Network-master/datasets.py | import cv2
import torch.utils.data as data
import torch
import os
import os.path
import numpy as np
import sys
import json
class IndoorPointRecord(object):
def __init__(self, path):
self.path = path
def call_input(self, mode, yaw):
return os.path.join(self.path, 'mode=%s_%d.png'%(mode, yaw))
... | 16,445 | 37.335664 | 120 | py |
View-Parsing-Network | View-Parsing-Network-master/models.py | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# File : models.py
# Author : Bowen Pan
# Email : panbowen0607@gmail.com
# Date : 09/18/2018
#
# Distributed under terms of the MIT license.
import torch
from torch import nn
import utils
from collections import OrderedDict
import torch.nn.functional as F
from segme... | 4,303 | 32.107692 | 98 | py |
View-Parsing-Network | View-Parsing-Network-master/test_seq.py | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# File : test.py
# Author : Bowen Pan
# Email : panbowen0607@gmail.com
# Date : 09/25/2018
#
# Distributed under terms of the MIT license.
"""
"""
from utils import Foo
from models import VPNModel
from datasets import Seq_OVMDataset
from opts import parser
from tra... | 9,394 | 34.996169 | 156 | py |
View-Parsing-Network | View-Parsing-Network-master/train_transfer.py | from utils import Foo
from models import VPNModel, FCDiscriminator
from datasets import House3D_Dataset, MP3D_Dataset, Carla_Dataset, nuScenes_Dataset
from opts import parser
from transform import *
import torchvision
import torch
from torch import nn
from torch.optim.lr_scheduler import MultiStepLR
from torch import o... | 15,782 | 40.101563 | 147 | py |
View-Parsing-Network | View-Parsing-Network-master/train.py | from utils import Foo
from models import VPNModel
from datasets import OVMDataset
from opts import parser
from transform import *
import torchvision
import torch
from torch import nn
from torch import optim
import os
import time
import shutil
mean_rgb = [0.485, 0.456, 0.406]
std_rgb = [0.229, 0.224, 0.225]
def main()... | 8,793 | 36.262712 | 147 | py |
View-Parsing-Network | View-Parsing-Network-master/train_carla.py | from utils import Foo
from models import VPNModel
from datasets import OVMDataset
from opts import parser
from transform import *
import torchvision
import torch
from torch import nn
from torch.optim.lr_scheduler import MultiStepLR
from torch import optim
import os
import time
from torch.nn.utils import clip_grad_norm
... | 8,964 | 36.354167 | 147 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/resnet.py | import os
import sys
import torch
import torch.nn as nn
import math
from segmentTool.lib.nn import SynchronizedBatchNorm2d
try:
from urllib import urlretrieve
except ImportError:
from urllib.request import urlretrieve
__all__ = ['ResNet', 'resnet18', 'resnet50', 'resnet101'] # resnet101 is coming soon!
mod... | 7,392 | 30.729614 | 99 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/resnext.py | import os
import sys
import torch
import torch.nn as nn
import math
from segmentTool.lib.nn import SynchronizedBatchNorm2d
try:
from urllib import urlretrieve
except ImportError:
from urllib.request import urlretrieve
__all__ = ['ResNeXt', 'resnext101'] # support resnext 101
model_urls = {
#'resnext50'... | 5,976 | 32.022099 | 101 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/models.py | import torch
import torch.nn as nn
import torchvision
from . import resnet, resnext
from segmentTool.lib.nn import SynchronizedBatchNorm2d
class SegmentationModuleBase(nn.Module):
def __init__(self):
super(SegmentationModuleBase, self).__init__()
def pixel_acc(self, pred, label):
_, preds = t... | 21,912 | 36.077834 | 114 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/nn/modules/replicate.py | # -*- coding: utf-8 -*-
# File : replicate.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import functools
from torch.nn.parallel.da... | 3,226 | 32.968421 | 115 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/nn/modules/unittest.py | # -*- coding: utf-8 -*-
# File : unittest.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import unittest
import numpy as np
from tor... | 835 | 26.866667 | 157 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/nn/modules/batchnorm.py | # -*- coding: utf-8 -*-
# File : batchnorm.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import collections
import torch
import tor... | 13,813 | 40.860606 | 127 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/nn/modules/tests/test_sync_batchnorm.py | # -*- coding: utf-8 -*-
# File : test_sync_batchnorm.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
import unittest
import torch
import torch.nn as nn
from torch.autograd import Variable
from sync_batchnorm import Synchroniz... | 3,571 | 30.892857 | 109 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/nn/modules/tests/test_numeric_batchnorm.py | # -*- coding: utf-8 -*-
# File : test_numeric_batchnorm.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
import unittest
import torch
import torch.nn as nn
from torch.autograd import Variable
from sync_batchnorm.unittest impor... | 1,615 | 27.350877 | 85 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/nn/parallel/data_parallel.py | # -*- coding: utf8 -*-
import torch.cuda as cuda
import torch.nn as nn
import torch
from torch.autograd import Variable
import collections
from torch.nn.parallel._functions import Gather
__all__ = ['UserScatteredDataParallel', 'user_scattered_collate', 'async_copy_to']
def async_copy_to(obj, dev, main_stream=None):
... | 3,493 | 29.649123 | 82 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/utils/th.py | import torch
from torch.autograd import Variable
import numpy as np
import collections
__all__ = ['as_variable', 'as_numpy', 'mark_volatile']
def as_variable(obj):
if isinstance(obj, Variable):
return obj
if isinstance(obj, collections.Sequence):
return [as_variable(v) for v in obj]
elif i... | 1,237 | 28.47619 | 60 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/utils/data/sampler.py | import torch
class Sampler(object):
"""Base class for all Samplers.
Every Sampler subclass has to provide an __iter__ method, providing a way
to iterate over indices of dataset elements, and a __len__ method that
returns the length of the returned iterators.
"""
def __init__(self, data_sourc... | 3,761 | 27.5 | 88 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/utils/data/dataloader.py | import torch
import torch.multiprocessing as multiprocessing
from torch._C import _set_worker_signal_handlers, _update_worker_pids, \
_remove_worker_pids, _error_if_any_worker_fails
from .sampler import SequentialSampler, RandomSampler, BatchSampler
import signal
import functools
import collections
import re
import... | 16,128 | 37.130024 | 102 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/utils/data/dataset.py | import bisect
import warnings
from torch._utils import _accumulate
from torch import randperm
class Dataset(object):
"""An abstract class representing a Dataset.
All other datasets should subclass it. All subclasses should override
``__len__``, that provides the size of the dataset, and ``__getitem__``,... | 3,465 | 28.12605 | 118 | py |
View-Parsing-Network | View-Parsing-Network-master/segmentTool/lib/utils/data/distributed.py | import math
import torch
from .sampler import Sampler
from torch.distributed import get_world_size, get_rank
class DistributedSampler(Sampler):
"""Sampler that restricts data loading to a subset of the dataset.
It is especially useful in conjunction with
:class:`torch.nn.parallel.DistributedDataParallel`... | 1,964 | 32.305085 | 86 | py |
acorns | acorns-master/docs/source/conf.py | # -*- coding: utf-8 -*-
#
# acorns documentation build configuration file, created by
# sphinx-quickstart on Thu Nov 23 10:21:51 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# Al... | 7,694 | 31.331933 | 79 | py |
messenger-emma | messenger-emma-main/evaluate.py | '''
Script for evaluating trained model performance from the command-line
'''
import argparse
import numpy as np
import torch
# Environment
import gym
import messenger
# models
from messenger.models.emma import EMMA
from messenger.models.utils import ObservationBuffer
def run_episode(model, env, args):
'''
... | 2,869 | 28.285714 | 119 | py |
messenger-emma | messenger-emma-main/setup.py | import setuptools
setuptools.setup(
name="messenger",
version="0.1.1",
author="Austin Wang Hanjie",
author_email="hjwang@cs.princeton.edu",
description="Implements EMMA model and Messenger environments.",
packages=setuptools.find_packages(),
python_requires='>=3.6',
install_requires=[
... | 521 | 25.1 | 68 | py |
messenger-emma | messenger-emma-main/run.py | '''
Script for evaluating trained model performance from the command-line
'''
import argparse
import gym
import torch
from messenger.models.emma import EMMA
from messenger.models.utils import ObservationBuffer
def win_episode(model, env, args):
'''
Run the model on env for one episode and return True if the ... | 2,114 | 28.788732 | 111 | py |
messenger-emma | messenger-emma-main/training/train_tools.py | import torch
import torch.nn as nn
class ObservationBuffer:
'''
Maintains a buffer of observations along the 0-dim.
Parameters:
buffer_size
How many previous observations to track in the buffer
device
The device on which buffers are loaded into
'''
def __init__(self, ... | 7,279 | 36.142857 | 155 | py |
messenger-emma | messenger-emma-main/training/model.py | '''
Code which implements the EMMA model
'''
import random
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
from numpy import sqrt as sqrt
from messenger.models.utils import nonzero_mean
class Memory:
""" Class to store information used by the PPO cl... | 8,218 | 34.123932 | 136 | py |
messenger-emma | messenger-emma-main/training/train.py | '''
Script for training models on stage 1, where the agent either starts with or with the goal
and the sole objective is to interact with the correct item.
'''
import argparse
import time
import pickle
import random
import hashlib
import gym
import messenger # this needs to be imported even though its not used to reg... | 9,963 | 35.903704 | 112 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.