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 |
|---|---|---|---|---|---|---|
mBNN | mBNN-main/MBNN/Polynomial.py | import argparse
from datetime import date
import os
import numpy as np
import copy
from datetime import datetime
from progress.bar import ChargingBar as Bar
import pickle
import seaborn as sns
import matplotlib.pyplot as plt
import sys
sys.path.append('..')
from utils import *
from evaluate import *
from MBNN.models... | 4,017 | 33.637931 | 135 | py |
mBNN | mBNN-main/MBNN/UCI.py | import argparse
from datetime import date
import os
import numpy as np
import copy
from datetime import datetime
from progress.bar import ChargingBar as Bar
import pickle
import sys
sys.path.append('..')
from utils import *
from evaluate import *
from MBNN.models import *
from MBNN.MCMC import *
from MBNN.Mask_Updat... | 9,295 | 43.908213 | 251 | py |
mBNN | mBNN-main/MBNN/models.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class M_relu(nn.Module):
def __init__(self, input_dim, init_active_dim):
super().__init__()
self.input_dim = input_dim
self.init_active_dim = init_active_dim
self.active = nn.P... | 5,411 | 41.28125 | 134 | py |
mBNN | mBNN-main/MBNN/MCMC.py | import numpy as np
import torch
import copy
def ll_regression(output, target, sigma):
exponent = -((target - output)**2).sum() / (2 * sigma**2)
log_coeff = (-0.5*torch.log(2*torch.tensor(np.pi))-torch.log(sigma))*output.shape[0]
return (log_coeff + exponent)
def log_prior(model):
l_prior = torch... | 6,201 | 37.04908 | 110 | py |
mBNN | mBNN-main/MBNN/Mask_Update.py | import copy
import numpy as np
import torch
from itertools import permutations
from MCMC import *
def mask_update_dataloader(model, task, dataloader, datasize, lam=0.1, N_max=3, death_method="proposed", birth_method="random"):
model.zero_grad()
for n, p in model.named_parameters():
if 'active' in n:
... | 7,489 | 40.381215 | 205 | py |
LTL-GATA | LTL-GATA-main/src/belief_graph.py | from typing import List, Tuple, Set, Union
import torch
from textworld.logic import Proposition
from utils import triplet_to_proposition, proposition_to_triplet
def exists_triplet(triplets, arg1, arg2, relation):
for i, t in enumerate(triplets):
if arg1 in [t[0], "*"] and\
arg2 in [t[1], "*"... | 5,241 | 33.261438 | 74 | py |
LTL-GATA | LTL-GATA-main/src/utils.py | from __future__ import annotations
from typing import List, Dict, Any, Union, Tuple, Deque
from pathlib import Path, PosixPath
from argparse import Namespace
import pickle
from logic import Variable, Proposition
import numpy as np
import torch
import yaml
MISSING_WORDS = set()
CONSTANT_NAMES = {"P": "player", "I":... | 11,080 | 34.289809 | 114 | py |
LTL-GATA | LTL-GATA-main/src/agent.py | from typing import Tuple, List, Dict, Any
from argparse import Namespace
from pathlib import Path
import logging
import copy
import json
import pdb
import torch.nn.functional as F
import numpy as np
import torch
from textworld import EnvInfos
from experience_replay import PrioritizedExperienceReplay
from components... | 29,311 | 44.234568 | 80 | py |
LTL-GATA | LTL-GATA-main/src/graph_updater.py | from typing import Tuple, List, Dict, Any
from pathlib import Path
import copy
import torch.nn.functional as F
import numpy as np
import torch
from utils import to_pt, max_len, pad_sequences, to_np
from model.layers import (
CQAttention, PointerSoftmax,
DecoderBlock, EncoderBlock, Embedding,
masked_softm... | 29,695 | 44.268293 | 79 | py |
LTL-GATA | LTL-GATA-main/src/optim/radam.py | import math
import torch
from torch.optim.optimizer import Optimizer, required
class RAdam(Optimizer):
def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=0, degenerated_to_sgd=True):
if not 0.0 <= lr:
raise ValueError("Invalid learning rate: {}".format(lr))
... | 11,028 | 39.848148 | 111 | py |
LTL-GATA | LTL-GATA-main/src/optim/__init__.py | from typing import Dict, Any
import torch
from optim.radam import RAdam
def get_optimizer(net: torch.nn.Module,
config: Dict[str, Any]) -> torch.optim.Optimizer:
# exclude some parameters from optimizer
param_frozen_list = [] # should be changed into torch.nn.ParameterList()
param_act... | 1,588 | 35.953488 | 77 | py |
LTL-GATA | LTL-GATA-main/src/model/features.py | from typing import List, Tuple
from argparse import Namespace
import pdb
from torch.autograd import Variable
import torch
from model.layers import Embedding, EncoderBlock, SelfAttention
from utils import max_len, to_pt, pad_sequences
class SimpleMLP(torch.nn.Module):
def __init__(self,
word_e... | 13,426 | 41.090909 | 78 | py |
LTL-GATA | LTL-GATA-main/src/model/utils.py | import torch
import math
def get_timing_signal(length: int, channels: int,
min_timescale: float = 1.0,
max_timescale: float = 1.0e4) -> torch.Tensor:
position = torch.arange(length).type(torch.float32)
num_timescales = channels // 2
log_timescale_increment = (ma... | 1,224 | 34 | 79 | py |
LTL-GATA | LTL-GATA-main/src/model/layers.py | import torch.nn.functional as F
import numpy as np
import torch
import h5py
from model.utils import PosEncoder, TreePosEncoder
class H5EmbeddingManager(object):
def __init__(self, h5_path):
f = h5py.File(h5_path, 'r')
self.W = np.array(f['embedding'])
# print("embedding data type=%s, shap... | 27,037 | 38.761765 | 143 | py |
LTL-GATA | LTL-GATA-main/src/model/__init__.py | from typing import List, Tuple
from argparse import Namespace
import logging
import pdb
import numpy as np
import torch
from utils import max_len, to_pt, pad_sequences
from components import Actions, Vocabulary
from model.features import TextEncoder
from model.layers import LSTMCell
from state import BatchedStates
... | 21,064 | 44.301075 | 79 | py |
period_graph | period_graph-master/period_graph/src/sage/mac_mp_queue.py |
# WARNING: Random code copied from off the internet.
# Code copied from https://github.com/keras-team/autokeras/issues/368
import multiprocessing
import multiprocessing.queues
class SharedCounter(object):
""" A synchronized shared counter.
The locking done by multiprocessing.Value ensures that only a singl... | 2,659 | 35.944444 | 108 | py |
period_graph | period_graph-master/period_graph/src/neural-network/model_bundle.py |
import os
import pickle as pk
from keras.models import load_model
class trivialPCA:
def __init__(self):
pass
def transform(self, x):
return x
class ModelBundle:
def __init__(self, *args, **kwds):
if len(args) == 1:
model_id = args[0]
PCA, MLP, CNN = ... | 7,104 | 32.833333 | 98 | py |
period_graph | period_graph-master/period_graph/src/neural-network/AI_eval.py | # Python 3.7.3.
## THIS FILE saves only to TestingOutputs
import os, sys, scipy.io, scipy.linalg, random, numpy as np
from time import time
###
# In CONFIG
# -- paths
# -- balance
# -- PCA (how many components
# -- number cohomology mats
# -- max-data-size : Read files until file sizes exceeds max-data-size
# -- outp... | 1,640 | 25.047619 | 77 | py |
period_graph | period_graph-master/period_graph/src/neural-network/AI_functions.py | ###############################################################################################
###############################################################################################
###############################################################################################
################################... | 7,500 | 33.726852 | 99 | py |
evaluate | evaluate-main/setup.py | # Lint as: python3
""" HuggingFace/Evaluate is an open library for evaluation.
Note:
VERSION needs to be formatted following the MAJOR.MINOR.PATCH convention
(we need to follow this convention to be able to retrieve versioned scripts)
Simple check list for release from AllenNLP repo: https://github.com/allenai... | 6,346 | 31.88601 | 116 | py |
evaluate | evaluate-main/src/evaluate/config.py | import importlib
import os
import platform
from pathlib import Path
from packaging import version
from .utils.logging import get_logger
logger = get_logger(__name__)
# Metrics
S3_METRICS_BUCKET_PREFIX = "https://s3.amazonaws.com/datasets.huggingface.co/datasets/metrics"
CLOUDFRONT_METRICS_DISTRIB_PREFIX = "https:... | 6,648 | 33.450777 | 118 | py |
evaluate | evaluate-main/src/evaluate/evaluator/base.py | # Copyright 2022 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... | 22,881 | 40.985321 | 178 | py |
evaluate | evaluate-main/src/evaluate/utils/file_utils.py | """
Utilities for working with the local dataset cache.
This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp
Copyright by the AllenNLP authors.
"""
import copy
import io
import json
import os
import posixpath
import re
import shutil
import sys
import tempfile
import time
import urllib
... | 22,602 | 35.515347 | 147 | py |
evaluate | evaluate-main/metrics/perplexity/perplexity.py | # Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.... | 8,460 | 42.839378 | 200 | py |
evaluate | evaluate-main/metrics/frugalscore/frugalscore.py | # Copyright 2022 The HuggingFace Datasets Authors and the current metric script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0... | 4,613 | 38.101695 | 231 | py |
evaluate | evaluate-main/metrics/comet/comet.py | # Copyright 2020 The HuggingFace Evaluate 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 6,967 | 39.511628 | 238 | py |
evaluate | evaluate-main/tests/test_evaluator.py | # Copyright 2022 The HuggingFace Datasets Authors and the TensorFlow Datasets 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... | 41,784 | 35.461606 | 119 | py |
evaluate | evaluate-main/tests/utils.py | import os
import tempfile
import unittest
from contextlib import contextmanager
from copy import deepcopy
from distutils.util import strtobool
from enum import Enum
from pathlib import Path
from unittest.mock import patch
from evaluate import config
def parse_flag_from_env(key, default=False):
try:
value... | 8,548 | 28.378007 | 108 | py |
evaluate | evaluate-main/tests/test_metric_common.py | # Copyright 2020 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 8,676 | 37.057018 | 118 | py |
evaluate | evaluate-main/tests/test_trainer_evaluator_parity.py | import json
import os
import shutil
import subprocess
import tempfile
import unittest
import numpy as np
import torch
import transformers
from datasets import load_dataset
from transformers import AutoFeatureExtractor, AutoModelForImageClassification, Trainer, TrainingArguments, pipeline
from evaluate import evaluato... | 11,804 | 36.595541 | 116 | py |
evaluate | evaluate-main/tests/test_metric.py | import os
import pickle
import tempfile
import time
from multiprocessing import Pool
from unittest import TestCase, mock
import pytest
from datasets.features import Features, Sequence, Value
from evaluate.module import EvaluationModule, EvaluationModuleInfo, combine
from .utils import require_tf, require_torch
cla... | 29,981 | 38.45 | 117 | py |
evaluate | evaluate-main/measurements/perplexity/perplexity.py | # Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.... | 8,604 | 43.35567 | 200 | py |
airloc | airloc-master/networks/rl_agent.py | import torch
import torch.nn as nn
import torch.nn.init as init
import math
import random
import sys
import os
import torch.nn.functional as F
from config import CONFIG
from networks.resnets import ResNet18
from torchvision.models.feature_extraction import get_graph_node_names
from torchvision.models.feature_extraction... | 3,679 | 30.724138 | 111 | py |
airloc | airloc-master/networks/agent.py | import torch
import importlib.util
import torch.nn as nn
import torch.nn.init as init
import math
import random
import sys
import os
import torch.nn.functional as F
from config import CONFIG
from networks.resnets import ResNet18
from torchvision.models.feature_extraction import get_graph_node_names
from torchvision.mod... | 13,032 | 40.243671 | 150 | py |
airloc | airloc-master/networks/RandomAgent.py | import torch
import importlib.util
import torch.nn as nn
import torch.nn.init as init
import math
import random
import sys
import os
import torch.nn.functional as F
from config import CONFIG
from networks.resnets import ResNet18
from torchvision.models.feature_extraction import get_graph_node_names
from torchvision.mod... | 2,861 | 30.450549 | 76 | py |
airloc | airloc-master/networks/rnn_agents.py |
import torch
import torch.nn as nn
import torchvision.transforms as transforms
import torch.nn.functional as F
import os
import importlib.util
import time
import json
import math
from utils.utils import calculate_cnn_output_size, cosine_sim_heatmap
from utils.agent_utils import visualize_cnn_filter, get_outside
import... | 18,173 | 43.004843 | 156 | py |
airloc | airloc-master/networks/deterministic_agent.py |
import torch
import importlib.util
import torch.nn as nn
import torch.nn.init as init
import math
import random
import sys
import os
import torch.nn.functional as F
from config import CONFIG
from networks.resnets import ResNet18
from torchvision.models.feature_extraction import get_graph_node_names
from torchvision.m... | 4,074 | 27.496503 | 113 | py |
airloc | airloc-master/networks/resnets.py |
import torch
import torch.nn as nn
import math
import random
import sys
import os
import torch.nn.functional as F
import torchvision.models as models
from torch.autograd import Variable
# During dev
#sys.path.append(os.path.abspath('..'))
#execfile(os.path.join(__file__, '../config.py'))
from config import CONFI... | 983 | 19.5 | 87 | py |
airloc | airloc-master/training/train_agent.py | import traceback
import pdb
from datetime import datetime
import random
import signal
import time
import numpy as np
import json
import os
import sys
# matplotlib is used for debugging image inputs to networks
import matplotlib
import matplotlib.pyplot as plt
from copy import deepcopy
import torch
import torch.nn as nn... | 16,125 | 37.122931 | 163 | py |
airloc | airloc-master/training/run_deterministic.py |
from datetime import datetime
import random
import time
import numpy as np
import json
from shutil import copyfile
import os
import sys
# matplotlib is used for debugging image inputs to networks
import matplotlib
import matplotlib.pyplot as plt
#matplotlib.use('TkAgg')
from copy import deepcopy
import torch
from to... | 12,201 | 33.179272 | 142 | py |
airloc | airloc-master/eval/eval_agent.py | from datetime import datetime
import random
import time
import numpy as np
import json
import os
import sys
import importlib
# matplotlib is used for debugging image inputs to networks
import matplotlib
import matplotlib.pyplot as plt
#matplotlib.use('TkAgg')
import torch
import torchvision.transforms as transforms
imp... | 11,306 | 40.417582 | 160 | py |
airloc | airloc-master/doerchnet/share_net.py |
import torch
import torch.nn as nn
from config import CONFIG
class ShareNet(nn.Module):
def __init__(self , num_out_classes = 8):
super(ShareNet, self).__init__()
# Check wether to include segmentation channel
if CONFIG.RL_priv_use_seg or CONFIG.RL_predict_seg_mask:
self... | 2,785 | 24.796296 | 115 | py |
airloc | airloc-master/doerchnet/utils.py | import torch
import numpy as np
import torchvision.transforms as transforms
import os
import gc
import matplotlib.patches as patches
import matplotlib.pyplot as plt
import urllib
import matplotlib
import random
from torch.nn.functional import one_hot
from config import CONFIG
from utils.utils import get_deterministic... | 16,618 | 40.967172 | 172 | py |
airloc | airloc-master/doerchnet/networks.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from config import CONFIG
class AJNet(nn.Module):
def __init__(self,net_type,mode = 'train', unit_size = 128,num_classes =8 , both_branches = True):
super(AJNet,self).__init__()
# Allow for pretraining network with ground t... | 4,630 | 27.763975 | 103 | py |
airloc | airloc-master/doerchnet/train.py | import os
import torch
import random
import torch.nn.functional as F
import torchvision.transforms as transforms
import torch.nn as nn
import json
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from shutil import copyfile
from utils.utils import get_random_crops, get_deterministic_crops, load_... | 12,721 | 36.528024 | 176 | py |
airloc | airloc-master/doerchnet/logs/with-sem-seg/share_net.py |
import torch
import torch.nn as nn
from config import CONFIG
class ShareNet(nn.Module):
def __init__(self , num_out_classes = 8):
super(ShareNet, self).__init__()
# Check wether to include segmentation channel
if CONFIG.RL_priv_use_seg or CONFIG.RL_predict_seg_mask:
self... | 2,784 | 25.028037 | 115 | py |
airloc | airloc-master/doerchnet/logs/without-sem-seg/share_net.py |
import torch
import torch.nn as nn
from config import CONFIG
class ShareNet(nn.Module):
def __init__(self , num_out_classes = 8):
super(ShareNet, self).__init__()
# Check wether to include segmentation channel
if CONFIG.RL_priv_use_seg:
self.seg_chan = 1
else:
... | 2,755 | 24.518519 | 115 | py |
airloc | airloc-master/doerchnet/logs/without-sem-seg-pre-michael/share_net.py |
import torch
import torch.nn as nn
from config import CONFIG
class ShareNet(nn.Module):
def __init__(self , num_out_classes = 8):
super(ShareNet, self).__init__()
# Check wether to include segmentation channel
if CONFIG.RL_priv_use_seg or CONFIG.RL_predict_seg_mask:
self... | 2,785 | 24.796296 | 115 | py |
airloc | airloc-master/doerchnet/logs/without-sem-seg-pre-michael/networks.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from config import CONFIG
class AJNet(nn.Module):
def __init__(self,net_type,mode = 'train', unit_size = 128,num_classes =8 , both_branches = True):
super(AJNet,self).__init__()
# Allow for pretraining network with ground t... | 4,630 | 27.763975 | 103 | py |
airloc | airloc-master/doerchnet/logs/without-sem-seg-pre-michael/train.py | import os
import torch
import random
import torch.nn.functional as F
import torchvision.transforms as transforms
import torch.nn as nn
import json
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from shutil import copyfile
from utils.utils import get_random_crops, get_deterministic_crops, load_... | 12,708 | 36.600592 | 176 | py |
airloc | airloc-master/segmentations/u_net.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from config import CONFIG
class UNet(nn.Module):
def __init__(self, n_channels, n_classes, bilinear=False):
super(UNet, self).__init__()
self.n_channels = n_channels
self.n_classes = n_classes
self.bilinear ... | 4,019 | 29.687023 | 122 | py |
airloc | airloc-master/segmentations/utils.py | from config import CONFIG
import math
import json
import os
import time
import zipfile
import gc
import numpy as np
import torch
import torchvision
import torchvision.transforms as transforms
from torchvision.datasets import ImageFolder
from torch.utils.data import random_split,Subset
import matplotlib
matplotlib.use(... | 5,241 | 27.802198 | 114 | py |
airloc | airloc-master/segmentations/unet_parts.py | """ Parts of the U-Net model """
import torch
import torch.nn as nn
import torch.nn.functional as F
class DoubleConv(nn.Module):
"""(convolution => [BN] => ReLU) * 2"""
def __init__(self, in_channels, out_channels, mid_channels=None):
super().__init__()
if not mid_channels:
mid_c... | 2,602 | 32.371795 | 122 | py |
airloc | airloc-master/segmentations/networks.py |
import random
from config import CONFIG
import torch
import torchvision.transforms as transforms
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from utils.utils import calculate_cnn_output_size
class BakeNet(nn.Module):
def __init__(self, n_out_chan = 2):
super(B... | 1,229 | 25.170213 | 73 | py |
airloc | airloc-master/segmentations/train.py |
import os
import torch
import random
import torchvision
import torchvision.transforms as transforms
import torch.nn.functional as F
import torch.nn as nn
import json
import numpy as np
from torchinfo import summary
from shutil import copyfile
from utils.utils import get_random_crops, get_deterministic_crops, load_n... | 9,545 | 32.261324 | 126 | py |
airloc | airloc-master/segmentations/logs/sem-seg-model/u_net.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from config import CONFIG
class UNet(nn.Module):
def __init__(self, n_channels, n_classes, bilinear=False):
super(UNet, self).__init__()
self.n_channels = n_channels
self.n_classes = n_classes
self.bilinear ... | 4,019 | 29.687023 | 122 | py |
airloc | airloc-master/utils/agent_utils.py |
import math
import os
import time
import zipfile
import warnings
import gc
import numpy as np
import torch
import torchvision
import torchvision.transforms as transforms
from torch.distributions import MultivariateNormal, OneHotCategorical
import matplotlib
import matplotlib.pyplot as plt
from torch.nn import Cross... | 16,432 | 31.158513 | 150 | py |
airloc | airloc-master/utils/dataset_utils.py | import os
import random
import torch
from PIL import Image
import pandas as pd
from torch.utils.data.dataset import Dataset
from torchvision import transforms
import torchvision.transforms.functional as F
import numpy as np
import glob
from config import CONFIG
import argparse
import sys
import time
class DubaiSeven(... | 37,541 | 36.617234 | 186 | py |
airloc | airloc-master/utils/utils.py | import math
import json
import os
import time
import zipfile
import signal
import pdb
import gc
from shutil import copyfile
import numpy as np
import torch
from glob import glob
# Might not be available on RISE
import seaborn as sns
import torchvision
import torchvision.transforms as transforms
from torchvision.datase... | 40,412 | 38.159884 | 181 | py |
airloc | airloc-master/utils/create_split_file.py |
import pandas as pd
import os
import matplotlib
import argparse
import torch
from utils.dataset_utils import *
import matplotlib.pyplot as plt
import torchvision.transforms as transforms
import time
import numpy as np
from doerchnet.utils import visualize_doerch
from utils.utils import sample_grid_games_fixed_distan... | 5,333 | 34.324503 | 143 | py |
airloc | airloc-master/utils/training_utils.py | import torch
import sys
import numpy as np
import torchvision.transforms as transforms
from copy import deepcopy
import time
import math
import torchvision.transforms.functional as F
from torchvision.transforms import Resize
from utils.agent_utils import rewards_to_go, normalize_batch_weights
from utils.utils import ... | 18,061 | 44.38191 | 181 | py |
airloc | airloc-master/utils/normalize_dataset.py | #!/bin/env python3
import os
import numpy as np
import imageio as iio
import time
import torch
import json
import torchvision.transforms as transforms
from torchvision.datasets import ImageFolder
from torch.utils.data import random_split,Subset
from utils.dataset_utils import CustomDataset, Dubai, Masa, MasaFilt, MasaF... | 4,167 | 37.592593 | 121 | py |
emcee3 | emcee3-master/docs/conf.py | # -*- coding: utf-8 -*-
import os
import sys
d = os.path.dirname
sys.path.insert(0, d(d(os.path.abspath(__file__))))
import emcee3 # NOQA
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx_gallery.gen_gallery",
]
templates_path = ["_templates"]
source_suffix = ... | 1,488 | 22.265625 | 62 | py |
u-unwrap3D | u-unwrap3D-master/docs/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 2,702 | 31.178571 | 79 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/fc.py | """
This code is from Jin-Hwa Kim, Jaehyun Jun, Byoung-Tak Zhang's repository.
https://github.com/jnhwkim/ban-vqa
"""
from __future__ import print_function
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
class FCNet(nn.Module):
"""Simple class for non-linear fully connect network
"""
... | 1,212 | 27.880952 | 76 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/main.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa)
"""
import os
import argparse
import torch
from torch.utils.data import DataLoader, ConcatDataset
import dataset_VQA
import base_model
from train import train
import utils
try:
import _pic... | 7,710 | 45.173653 | 132 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/base_model.py | """
This code is developed based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import torch
import torch.nn as nn
from attention import BiAttention, StackedAttention
from language_model import WordEmbedding, QuestionEmbedding
from classifier import... | 11,762 | 44.949219 | 141 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/test.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import argparse
import torch
from torch.utils.data import DataLoader
import dataset_VQA
import base_model
import utils
import pandas as pd
import os
import json
answer_typ... | 12,886 | 45.189964 | 154 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/dataset_VQA.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
from __future__ import print_function
import os
import json
import _pickle as cPickle
import numpy as np
import utils
import torch
from language_model import WordEmbedding... | 12,877 | 38.024242 | 146 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/learner.py | import torch
from torch import nn
from torch.nn import functional as F
import numpy as np
class MAML(nn.Module):
"""
Meta Learner
"""
def __init__(self, dataset_dir):
"""
:param args:
"""
super(MAML, self).__init__()
if 'RAD' in dataset_dir:
... | 9,463 | 34.051852 | 111 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/counting.py | """
Learning to Count Objects in Natural Images for Visual Question Answering
Yan Zhang, Jonathon Hare, Adam Prügel-Bennett
ICLR 2018
This code is from Yan Zhang's repository.
https://github.com/Cyanogenoid/vqa-counting/blob/master/vqa-v2/counting.py
MIT License
"""
import torch
import torch.nn as nn
from torch.autogr... | 7,535 | 42.310345 | 298 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/utils.py | """
This code is extended from Hengyuan Hu's repository.
https://github.com/hengyuan-hu/bottom-up-attention-vqa
"""
from __future__ import print_function
import errno
import os
import re
import collections
import numpy as np
import operator
import functools
from PIL import Image
import torch
import torch.nn as nn
impo... | 12,029 | 33.371429 | 117 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/classifier.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
class SimpleClassifier(nn.Module):
def __init__(self, in_dim, hid_dim, out_dim, args):
... | 936 | 35.038462 | 140 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/simple_cnn.py | """
MAML module for MEVF model
This code is written by Binh X. Nguyen and Binh D. Nguyen
<link paper>
"""
import torch
import torch.nn as nn
import numpy as np
import pickle
import torch.nn.functional as F
class SimpleCNN(nn.Module):
def __init__(self, weight_path='simple_cnn.weights', eps_cnn=1e-5, momentum_cnn=0... | 4,169 | 41.121212 | 104 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/bc.py | """
This code is from Jin-Hwa Kim, Jaehyun Jun, Byoung-Tak Zhang's repository.
https://github.com/jnhwkim/ban-vqa
"""
from __future__ import print_function
import torch
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
from fc import FCNet
class BCNet(nn.Module):
"""Simple class for non-lin... | 3,408 | 40.573171 | 119 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/attention.py | """
This code is extended from Jin-Hwa Kim, Jaehyun Jun, Byoung-Tak Zhang's repository.
https://github.com/jnhwkim/ban-vqa
This code is modified from ZCYang's repository.
https://github.com/zcyang/imageqa-san
"""
import torch
import torch.nn as nn
from torch.nn.utils.weight_norm import weight_norm
from bc import BCNet... | 4,448 | 33.488372 | 101 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/train.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import os
import time
import torch
import utils
import torch.nn as nn
from trainer import Trainer
warmup_updates = 4000
# Kaiming normalization initialization
def init_we... | 6,862 | 39.609467 | 282 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/auto_encoder.py | """
Auto-encoder module for MEVF model
This code is written by Binh X. Nguyen and Binh D. Nguyen
<link paper>
"""
import torch.nn as nn
from torch.distributions.normal import Normal
import functools
import operator
import torch.nn.functional as F
import torch
def add_noise(images, mean=0, std=0.1):
normal_dst = No... | 2,019 | 32.114754 | 106 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/trainer.py | """
This code is modified based on Jin-Hwa Kim's repository (Bilinear Attention Networks - https://github.com/jnhwkim/ban-vqa) by Xuan B. Nguyen
"""
import torch
import utils
import contextlib
from collections import defaultdict, OrderedDict
from meters import AverageMeter, TimeMeter
class Trainer(object):
"""
... | 9,194 | 36.226721 | 152 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/language_model.py | """
This code is from Jin-Hwa Kim, Jaehyun Jun, Byoung-Tak Zhang's repository.
https://github.com/jnhwkim/ban-vqa
"""
import torch
import torch.nn as nn
from torch.autograd import Variable
import numpy as np
class WordEmbedding(nn.Module):
"""Word Embedding
The ntoken-th dim is used for padding_idx, which agr... | 3,405 | 35.234043 | 94 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/meters.py | """
This code is from https://github.com/pytorch/fairseq
"""
import time
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0
... | 1,513 | 21.264706 | 66 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/VQA_RAD_train.py | import torch, os
import numpy as np
from VQA_RAD import VQARAD_maml
import scipy.stats
from torch.utils.data import DataLoader
import argparse
import time
from meta import Meta
def mean_confidence_interval(accs, confidence=0.95):
n = accs.shape[0]
m, se = np.mean(accs), scipy.stats.sem(accs)
h =... | 4,249 | 37.990826 | 137 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/VQA_RAD_fuse.py | import torch, os
import numpy as np
from VQA_RAD import VQARAD_maml
import scipy.stats
from torch.utils.data import DataLoader
import argparse
import time
from meta import Meta
import pickle as p
def mean_confidence_interval(accs, confidence=0.95):
n = accs.shape[0]
m, se = np.mean(accs), scipy.stat... | 7,237 | 40.597701 | 145 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/pathVQA_maml.py | import os
import torch
from torch.utils.data import Dataset
from torchvision.transforms import transforms
import numpy as np
from PIL import Image
import random
class PathVQA_maml(Dataset):
"""
NOTICE: meta-learning is different from general supervised learning, especially the concept of batch and set.
ba... | 12,430 | 47.74902 | 155 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/learner.py | import torch
from torch import nn
from torch.nn import functional as F
import numpy as np
class Learner(nn.Module):
"""
"""
def __init__(self, config, imgc, imgsz):
"""
:param config: network config file, type:list of (string, list)
:param imgc: 1 or 3
:param im... | 7,789 | 34.733945 | 111 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/VQA_RAD.py | import os
import torch
from torch.utils.data import Dataset
from torchvision.transforms import transforms
import numpy as np
from PIL import Image
import random
class VQARAD_maml(Dataset):
"""
NOTICE: meta-learning is different from general supervised learning, especially the concept of batch and set.
bat... | 11,779 | 46.692308 | 155 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/pathVQA_maml_train.py | import torch, os
import numpy as np
from pathVQA_maml import PathVQA_maml
import scipy.stats
from torch.utils.data import DataLoader
import argparse
import time
from meta import Meta
def mean_confidence_interval(accs, confidence=0.95):
n = accs.shape[0]
m, se = np.mean(accs), scipy.stats.sem(accs)
... | 5,532 | 40.291045 | 143 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/pathVQA_maml_fuse.py | import torch, os
import numpy as np
from pathVQA_maml import PathVQA_maml
import scipy.stats
from torch.utils.data import DataLoader
import argparse
import time
from meta import Meta
import pickle as p
def mean_confidence_interval(accs, confidence=0.95):
n = accs.shape[0]
m, se = np.mean(accs), scipy... | 7,202 | 39.926136 | 141 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/VQA_RAD_half.py | import torch, os
import numpy as np
from VQA_RAD import VQARAD_maml
import scipy.stats
from torch.utils.data import DataLoader
import argparse
import time
from meta import Meta
import shutil
def mean_confidence_interval(accs, confidence=0.95):
n = accs.shape[0]
m, se = np.mean(accs), scipy.stats.sem(... | 8,795 | 38.621622 | 138 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/meta.py | import torch
from torch import nn
from torch import optim
from torch.nn import functional as F
from torch.utils.data import TensorDataset, DataLoader
from torch import optim
import numpy as np
from learner import Learner
from copy import deepcopy
class Meta(nn.Module):
"""
Meta Learne... | 12,796 | 34.350829 | 110 | py |
MICCAI21_MMQ | MICCAI21_MMQ-main/mmq_maml/pathVQA_maml_half.py | import torch, os
import numpy as np
from pathVQA_maml import PathVQA_maml
import scipy.stats
from torch.utils.data import DataLoader
import argparse
import time
from meta import Meta
import shutil
def mean_confidence_interval(accs, confidence=0.95):
n = accs.shape[0]
m, se = np.mean(accs), scipy.stat... | 8,907 | 38.591111 | 144 | py |
pytorch-CycleGAN-and-pix2pix | pytorch-CycleGAN-and-pix2pix-master/test.py | """General-purpose test script for image-to-image translation.
Once you have trained your model with train.py, you can use this script to test the model.
It will load a saved model from '--checkpoints_dir' and save the results to '--results_dir'.
It first creates model and dataset given the option. It will hard-code ... | 4,545 | 55.123457 | 130 | py |
pytorch-CycleGAN-and-pix2pix | pytorch-CycleGAN-and-pix2pix-master/train.py | """General-purpose training script for image-to-image translation.
This script works for various models (with option '--model': e.g., pix2pix, cyclegan, colorization) and
different datasets (with option '--dataset_mode': e.g., aligned, unaligned, single, colorization).
You need to specify the dataset ('--dataroot'), e... | 4,933 | 62.25641 | 186 | py |
pytorch-CycleGAN-and-pix2pix | pytorch-CycleGAN-and-pix2pix-master/options/base_options.py | import argparse
import os
from util import util
import torch
import models
import data
class BaseOptions():
"""This class defines options used during both training and test time.
It also implements several helper functions such as parsing, printing, and saving the options.
It also gathers additional opti... | 8,327 | 58.485714 | 235 | py |
pytorch-CycleGAN-and-pix2pix | pytorch-CycleGAN-and-pix2pix-master/models/base_model.py | import os
import torch
from collections import OrderedDict
from abc import ABC, abstractmethod
from . import networks
class BaseModel(ABC):
"""This class is an abstract base class (ABC) for models.
To create a subclass, you need to implement the following five functions:
-- <__init__>: ... | 10,407 | 44.056277 | 260 | py |
pytorch-CycleGAN-and-pix2pix | pytorch-CycleGAN-and-pix2pix-master/models/colorization_model.py | from .pix2pix_model import Pix2PixModel
import torch
from skimage import color # used for lab2rgb
import numpy as np
class ColorizationModel(Pix2PixModel):
"""This is a subclass of Pix2PixModel for image colorization (black & white image -> colorful images).
The model training requires '-dataset_model color... | 3,013 | 42.681159 | 141 | py |
pytorch-CycleGAN-and-pix2pix | pytorch-CycleGAN-and-pix2pix-master/models/pix2pix_model.py | import torch
from .base_model import BaseModel
from . import networks
class Pix2PixModel(BaseModel):
""" This class implements the pix2pix model, for learning a mapping from input images to output images given paired data.
The model training requires '--dataset_mode aligned' dataset.
By default, it uses ... | 6,519 | 49.9375 | 162 | py |
pytorch-CycleGAN-and-pix2pix | pytorch-CycleGAN-and-pix2pix-master/models/networks.py | import torch
import torch.nn as nn
from torch.nn import init
import functools
from torch.optim import lr_scheduler
###############################################################################
# Helper Functions
###############################################################################
class Identity(nn.Modu... | 28,408 | 45.04376 | 167 | py |
pytorch-CycleGAN-and-pix2pix | pytorch-CycleGAN-and-pix2pix-master/models/template_model.py | """Model class template
This module provides a template for users to implement custom models.
You can specify '--model template' to use this model.
The class name should be consistent with both the filename and its model option.
The filename should be <model>_dataset.py
The class name should be <Model>Dataset.py
It im... | 5,951 | 58.52 | 177 | py |
pytorch-CycleGAN-and-pix2pix | pytorch-CycleGAN-and-pix2pix-master/models/cycle_gan_model.py | import torch
import itertools
from util.image_pool import ImagePool
from .base_model import BaseModel
from . import networks
class CycleGANModel(BaseModel):
"""
This class implements the CycleGAN model, for learning image-to-image translation without paired data.
The model training requires '--dataset_mo... | 10,557 | 53.14359 | 362 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.