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 |
|---|---|---|---|---|---|---|
gbm-bench | gbm-bench-master/runme.py | #!/usr/bin/env python
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, thi... | 6,334 | 42.095238 | 97 | py |
gbm-bench | gbm-bench-master/3rdparty/fast_retraining/experiments/libs/loaders.py | import os
import pandas as pd
import arff
import numpy as np
from functools import reduce
import sqlite3
import logging
from libs.planet_kaggle import (to_multi_label_dict, get_file_count, enrich_with_feature_encoding,
featurise_images, generate_validation_files)
import tensorflow as tf... | 12,263 | 48.853659 | 356 | py |
gbm-bench | gbm-bench-master/3rdparty/fast_retraining/experiments/libs/planet_kaggle.py | import os
import numpy as np
import glob
from tqdm import tqdm
import shutil
from keras.preprocessing import image
from keras.applications.imagenet_utils import preprocess_input
def labels_from(labels_df):
""" Extracts the unique labels from the labels dataframe
"""
# Build list with unique labels
lab... | 2,761 | 30.033708 | 110 | py |
dataqa | dataqa-master/continuum/validation_tool/report.py | from __future__ import division
from functions import get_pixel_area, get_stats, flux_at_freq, axis_lim
import os
import collections
from datetime import datetime
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt, mpld3
from matplotlib import cm, ticker, colors
from mpld3 import plugins
from matp... | 69,888 | 39.63314 | 156 | py |
robust-nli | robust-nli-master/src/losses.py | import torch
import torch.nn as nn
import torch.nn.functional as F
def convert_2d_prob_to_3d(prob_dist):
prob_dist = torch.cat([(prob_dist[:, 0] / 2.0).view(-1, 1),
prob_dist[:, 1].view(-1, 1),
(prob_dist[:, 0] / 2.0).view(-1, 1)], dim=1)
return prob_dist
... | 4,401 | 35.081967 | 116 | py |
robust-nli | robust-nli-master/src/BERT/utils_glue.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 29,876 | 37.550968 | 154 | py |
robust-nli | robust-nli-master/src/BERT/run_glue.py | """ Finetuning the library models for sequence classification on GLUE (Bert, XLM, XLNet)."""
from __future__ import absolute_import, division, print_function
import logging
import os
import random
from utils_glue import GLUE_TASKS_NUM_LABELS
from eval_utils import load_and_cache_examples, evaluate, get_parser
import ... | 13,321 | 42.966997 | 163 | py |
robust-nli | robust-nli-master/src/BERT/utils_bert.py | import torch
from torch import nn
import sys
sys.path.append("../")
from torch.nn import CrossEntropyLoss, MSELoss
from pytorch_transformers.modeling_bert import BertPreTrainedModel, BertModel
from losses import FocalLoss, POELoss, RUBILoss
from utils_glue import get_word_similarity_new, get_length_features
from mutil... | 12,786 | 48.949219 | 134 | py |
robust-nli | robust-nli-master/src/BERT/eval_utils.py | from torch.utils.data import (DataLoader, SequentialSampler, TensorDataset)
from os.path import join
import numpy as np
from utils_glue import (compute_metrics, convert_examples_to_features,
processors)
import argparse
import torch
import os
import glob
import logging
from tqdm import tqdm, tran... | 25,678 | 51.620902 | 135 | py |
robust-nli | robust-nli-master/src/BERT/mutils.py | import csv
import os
import torch
def write_to_csv(scores, params, outputfile):
"""
This function writes the parameters and the scores with their names in a
csv file.
"""
# creates the file if not existing.
file = open(outputfile, 'a')
# If file is empty writes the keys to the file.
p... | 1,741 | 30.107143 | 77 | py |
robust-nli | robust-nli-master/src/InferSent/data.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import os
import numpy as np
import torch
def get_batch(batch, word_vec, emb_dim=300):
# sent in batch in decreasing order ... | 3,317 | 33.926316 | 84 | py |
robust-nli | robust-nli-master/src/InferSent/models.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
This file contains the definition of encoders used in https://arxiv.org/pdf/1705.02364.pdf
"""
import time
import sys
sys.... | 15,032 | 34.878282 | 115 | py |
robust-nli | robust-nli-master/src/InferSent/train_nli.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import sys
import time
import argparse
import os
import numpy as np
import torch
from torch.autograd import Variable
from d... | 14,974 | 39.582656 | 130 | py |
robust-nli | robust-nli-master/src/InferSent/mutils.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import re
import inspect
from torch import optim
import torch
import os
import csv
def construct_model_name(params, names_par... | 4,580 | 28.941176 | 79 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/main.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the root directory of this source tree
##++++++++++++++... | 4,678 | 54.702381 | 133 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/trainer/meta.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Modified from: https://github.com/Sha-Lab/FEAT
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the r... | 13,374 | 44.493197 | 143 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/trainer/pre.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the root directory of this source tree
##++++++++++++++... | 9,314 | 42.528037 | 139 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/models/mtl.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the root directory of this source tree
##++++++++++++++... | 5,292 | 38.796992 | 115 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/models/conv2d_mtl.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Modified from: https://github.com/pytorch/pytorch
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in th... | 4,195 | 40.137255 | 94 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/models/resnet_mtl.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Modified from: https://github.com/Sha-Lab/FEAT
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the r... | 6,842 | 30.246575 | 90 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/utils/misc.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Modified from: https://github.com/Sha-Lab/FEAT
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the r... | 2,219 | 24.227273 | 75 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/utils/gpu_tools.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the root directory of this source tree
##++++++++++++++... | 547 | 31.235294 | 75 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/dataloader/dataset_loader.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Modified from: https://github.com/Sha-Lab/FEAT
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the r... | 3,153 | 37.463415 | 125 | py |
meta-transfer-learning | meta-transfer-learning-main/pytorch/dataloader/samplers.py | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Modified from: https://github.com/Sha-Lab/FEAT
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the r... | 1,381 | 32.707317 | 75 | py |
adventures-in-ml-code | adventures-in-ml-code-master/keras_word2vec.py | from keras.models import Model
from keras.layers import Input, Dense, Reshape, merge
from keras.layers.embeddings import Embedding
from keras.preprocessing.sequence import skipgrams
from keras.preprocessing import sequence
import urllib
import collections
import os
import zipfile
import numpy as np
import tensorflow ... | 5,397 | 34.513158 | 101 | py |
adventures-in-ml-code | adventures-in-ml-code-master/dueling_q_tf2_atari.py | import gym
import tensorflow as tf
from tensorflow import keras
import random
import numpy as np
import datetime as dt
import imageio
STORE_PATH = 'C:\\Users\\Andy\\TensorFlowBook\\TensorBoard'
MAX_EPSILON = 1
MIN_EPSILON = 0.1
EPSILON_MIN_ITER = 500000
GAMMA = 0.99
BATCH_SIZE = 32
TAU = 0.08
POST_PROCESS_IMAGE_SIZE =... | 8,874 | 39.711009 | 125 | py |
adventures-in-ml-code | adventures-in-ml-code-master/policy_gradient_reinforce_tf2.py | import gym
import tensorflow as tf
from tensorflow import keras
import numpy as np
import datetime as dt
STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard/PolicyGradientCartPole'
GAMMA = 0.95
env = gym.make("CartPole-v0")
state_size = 4
num_actions = env.action_space.n
network = keras.Seq... | 2,344 | 34 | 116 | py |
adventures-in-ml-code | adventures-in-ml-code-master/per_duelingq_spaceinv_tf2.py | import gym
import tensorflow as tf
from tensorflow import keras
import random
import numpy as np
import datetime as dt
import imageio
import os
# STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard'
# STORE_PATH = "tensorboard"
STORE_PATH = "C:\\Users\\Andy\\TensorFlowBook\\TensorBoard"
MAX_E... | 13,766 | 40.844985 | 165 | py |
adventures-in-ml-code | adventures-in-ml-code-master/gensim_word2vec.py | import gensim
from gensim.models import word2vec
import logging
from keras.layers import Input, Embedding, merge
from keras.models import Model
import tensorflow as tf
import numpy as np
import urllib.request
import os
import zipfile
vector_dim = 300
root_path = "C:\\Users\Andy\PycharmProjects\\adventures-in-ml-cod... | 7,078 | 38.327778 | 120 | py |
adventures-in-ml-code | adventures-in-ml-code-master/a2c_tf2_cartpole.py | import tensorflow as tf
from tensorflow import keras
import numpy as np
import gym
import datetime as dt
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard/A2CCartPole'
CRITIC_LOSS_WEIGHT = 0.5
ACTOR_LOSS_WEIGHT = 1.0
ENTROPY_LOSS_WEIGHT ... | 4,312 | 32.96063 | 118 | py |
adventures-in-ml-code | adventures-in-ml-code-master/pytorch_nn.py | import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
def simple_gradient():
# print the gradient of 2x^2 + 5x
x = Variable(torch.ones(2, 2) * 2, requires_grad=True)
z = 2 * (x * x) + ... | 3,316 | 33.915789 | 81 | py |
adventures-in-ml-code | adventures-in-ml-code-master/tensor_flow_tutorial.py | import tensorflow as tf
import numpy as np
import datetime as dt
from tensorflow.keras.datasets import mnist
STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorBoard'
def run_simple_graph():
# create TensorFlow variables
const = tf.Variable(2.0, name="const")
b = tf.Variable(2.0, name='b')
c = t... | 4,411 | 32.424242 | 103 | py |
adventures-in-ml-code | adventures-in-ml-code-master/double_q_tensorflow2.py | import gym
import tensorflow as tf
from tensorflow import keras
import random
import numpy as np
import datetime as dt
import math
STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard'
MAX_EPSILON = 1
MIN_EPSILON = 0.01
LAMBDA = 0.0005
GAMMA = 0.95
BATCH_SIZE = 32
TAU = 0.08
RANDOM_REWARD_STD ... | 4,711 | 32.41844 | 118 | py |
adventures-in-ml-code | adventures-in-ml-code-master/keras_lstm.py | from __future__ import print_function
import collections
import os
import tensorflow as tf
from keras.models import Sequential, load_model
from keras.layers import Dense, Activation, Embedding, Dropout, TimeDistributed
from keras.layers import LSTM
from keras.optimizers import Adam
from keras.utils import to_categorica... | 7,148 | 39.619318 | 109 | py |
adventures-in-ml-code | adventures-in-ml-code-master/dueling_q_tensorflow2.py | import gym
import tensorflow as tf
from tensorflow import keras
import random
import numpy as np
import datetime as dt
import math
STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard'
MAX_EPSILON = 1
MIN_EPSILON = 0.01
EPSILON_MIN_ITER = 5000
DELAY_TRAINING = 300
GAMMA = 0.95
BATCH_SIZE = 32
... | 6,519 | 35.629213 | 118 | py |
adventures-in-ml-code | adventures-in-ml-code-master/tf_visualization.py | import tensorflow as tf
import numpy as np
from tensorflow.keras.datasets import mnist
STORE_PATH = 'C:\\Users\\Andy\\TensorFlowBook\\TensorBoard'
def get_batch(x_data, y_data, batch_size):
idxs = np.random.randint(0, len(y_data), batch_size)
return x_data[idxs,:,:], y_data[idxs]
def nn_example():
(x_tra... | 4,100 | 44.065934 | 113 | py |
adventures-in-ml-code | adventures-in-ml-code-master/ppo_tf2_cartpole.py | import tensorflow as tf
from tensorflow import keras
import tensorflow_probability as tfp
import numpy as np
import gym
import datetime as dt
STORE_PATH = 'C:\\Users\\andre\\TensorBoard\\PPOCartpole'
CRITIC_LOSS_WEIGHT = 0.5
ENTROPY_LOSS_WEIGHT = 0.01
ENT_DISCOUNT_RATE = 0.995
BATCH_SIZE = 64
GAMMA = 0.99
CLIP_VALUE ... | 6,351 | 35.297143 | 119 | py |
adventures-in-ml-code | adventures-in-ml-code-master/keras_eager_tf_2.py | import tensorflow as tf
from tensorflow import keras
import datetime as dt
tf.enable_eager_execution()
(x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data()
# prepare training data
train_dataset = tf.data.Dataset.from_tensor_slices((x_train, y_train)).batch(32).shuffle(10000)
train_dataset = trai... | 3,037 | 44.343284 | 128 | py |
adventures-in-ml-code | adventures-in-ml-code-master/r_learning_python.py | import gym
import numpy as np
from keras.models import Sequential
from keras.layers import Dense, InputLayer
import matplotlib.pylab as plt
env = gym.make('NChain-v0')
def naive_sum_reward_agent(env, num_episodes=500):
# this is the table that will hold our summated rewards for
# each action in each state
... | 4,424 | 32.522727 | 94 | py |
adventures-in-ml-code | adventures-in-ml-code-master/conv_net_py_torch.py | import torch
import torch.nn as nn
from torch.utils.data import DataLoader
import torchvision.transforms as transforms
import torchvision.datasets
from bokeh.plotting import figure
from bokeh.io import show
from bokeh.models import LinearAxis, Range1d
import numpy as np
# Hyperparameters
num_epochs = 6
num_classes = ... | 3,793 | 32.575221 | 102 | py |
adventures-in-ml-code | adventures-in-ml-code-master/keras_cnn.py | from __future__ import print_function
import keras
from keras.datasets import mnist
from keras.layers import Dense, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras.models import Sequential
import matplotlib.pylab as plt
batch_size = 128
num_classes = 10
epochs = 10
# input image dimensions
img_x, img... | 2,477 | 31.181818 | 96 | py |
query-selected-attention | query-selected-attention-main/test.py | import os
import torch
from options.test_options import TestOptions
from data import create_dataset
from models import create_model
from util.visualizer import save_images
from util import html
import util.util as util
if __name__ == '__main__':
opt = TestOptions().parse() # get test options
# hard-code some... | 2,235 | 49.818182 | 123 | py |
query-selected-attention | query-selected-attention-main/train.py | import time
import torch
from options.train_options import TrainOptions
from data import create_dataset
from models import create_model
from util.visualizer import Visualizer
if __name__ == '__main__':
opt = TrainOptions().parse() # get training options
dataset = create_dataset(opt) # create a dataset give... | 4,279 | 55.315789 | 186 | py |
query-selected-attention | query-selected-attention-main/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... | 9,260 | 57.613924 | 287 | py |
query-selected-attention | query-selected-attention-main/models/base_model.py | import os
import torch
from collections import OrderedDict
from abc import ABC, abstractmethod
from . import networks_global
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__>: ... | 11,231 | 42.366795 | 260 | py |
query-selected-attention | query-selected-attention-main/models/patchnce.py | from packaging import version
import torch
from torch import nn
class PatchNCELoss(nn.Module):
def __init__(self, opt):
super().__init__()
self.opt = opt
self.cross_entropy_loss = torch.nn.CrossEntropyLoss(reduction='none')
self.mask_dtype = torch.uint8 if version.parse(torch.__ver... | 1,598 | 38 | 114 | py |
query-selected-attention | query-selected-attention-main/models/qs_model.py | import numpy as np
import torch
from .base_model import BaseModel
from . import networks_global, networks_local, networks_local_global
from .patchnce import PatchNCELoss
import util.util as util
class QSModel(BaseModel):
@staticmethod
def modify_commandline_options(parser, is_train=True):
parser.add_a... | 9,580 | 47.145729 | 204 | py |
query-selected-attention | query-selected-attention-main/models/networks_local.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
import functools
from torch.optim import lr_scheduler
import numpy as np
###############################################################################
# Helper Functions
######################################################... | 61,828 | 42.480309 | 187 | py |
query-selected-attention | query-selected-attention-main/models/networks_global.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
import functools
from torch.optim import lr_scheduler
import numpy as np
###############################################################################
# Helper Functions
######################################################... | 61,118 | 42.19364 | 187 | py |
query-selected-attention | query-selected-attention-main/models/networks_local_global.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
import functools
from torch.optim import lr_scheduler
import numpy as np
###############################################################################
# Helper Functions
######################################################... | 61,819 | 42.443429 | 187 | py |
query-selected-attention | query-selected-attention-main/util/image_pool.py | import random
import torch
class ImagePool():
"""This class implements an image buffer that stores previously generated images.
This buffer enables us to update discriminators using a history of generated images
rather than the ones produced by the latest generators.
"""
def __init__(self, pool_... | 2,226 | 39.490909 | 140 | py |
query-selected-attention | query-selected-attention-main/util/util.py | """This module contains simple helper functions """
from __future__ import print_function
import torch
import numpy as np
from PIL import Image
import os
import importlib
import argparse
from argparse import Namespace
import torchvision
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in... | 5,135 | 29.754491 | 145 | py |
query-selected-attention | query-selected-attention-main/data/base_dataset.py | """This module implements an abstract base class (ABC) 'BaseDataset' for datasets.
It also includes common transformation functions (e.g., get_transform, __scale_width), which can be later used in subclasses.
"""
import random
import numpy as np
import torch.utils.data as data
from PIL import Image
import torchvision.... | 8,026 | 33.748918 | 153 | py |
query-selected-attention | query-selected-attention-main/data/image_folder.py | """A modified image folder class
We modify the official PyTorch image folder (https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py)
so that this class can load images from both current directory and its subdirectories.
"""
import torch.utils.data as data
from PIL import Image
import os
import... | 1,941 | 27.985075 | 122 | py |
query-selected-attention | query-selected-attention-main/data/__init__.py | """This package includes all the modules related to data loading and preprocessing
To add a custom dataset class called 'dummy', you need to add a file called 'dummy_dataset.py' and define a subclass 'DummyDataset' inherited from BaseDataset.
You need to implement four functions:
-- <__init__>: ... | 3,667 | 36.050505 | 176 | py |
bottom-up-attention | bottom-up-attention-master/tools/compress_net.py | #!/usr/bin/env python
# --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Compress a Fast R-CNN network using truncated... | 3,918 | 30.103175 | 81 | py |
bottom-up-attention | bottom-up-attention-master/tools/train_faster_rcnn_alt_opt.py | #!/usr/bin/env python
# --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Train a Faster R-CNN network using alternat... | 12,871 | 37.423881 | 80 | py |
bottom-up-attention | bottom-up-attention-master/tools/test_net.py | #!/usr/bin/env python
# --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Test a Fast R-CNN network on an image databas... | 3,742 | 35.696078 | 111 | py |
bottom-up-attention | bottom-up-attention-master/tools/_init_paths.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Set up paths for Fast R-CNN."""
import os.path as osp
import sys
d... | 627 | 23.153846 | 58 | py |
bottom-up-attention | bottom-up-attention-master/tools/demo_rfcn.py | #!/usr/bin/env python
# --------------------------------------------------------
# R-FCN
# Copyright (c) 2016 Yuwen Xiong
# Licensed under The MIT License [see LICENSE for details]
# Written by Yuwen Xiong
# --------------------------------------------------------
"""
Demo script showing detections in sample images.
... | 4,938 | 31.708609 | 85 | py |
bottom-up-attention | bottom-up-attention-master/tools/demo.py | #!/usr/bin/env python
# --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""
Demo script showing detections in sample i... | 5,123 | 31.846154 | 80 | py |
bottom-up-attention | bottom-up-attention-master/tools/train_svms.py | #!/usr/bin/env python
# --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""
Train post-hoc SVMs using the algorithm and ... | 13,480 | 37.081921 | 80 | py |
bottom-up-attention | bottom-up-attention-master/tools/train_net_multi_gpu.py | #!/usr/bin/env python
# --------------------------------------------------------
# Written by Bharat Singh
# Modified version of py-R-FCN
# --------------------------------------------------------
"""Train a Fast R-CNN network on a region of interest database."""
import _init_paths
from fast_rcnn.train_multi_gpu imp... | 3,684 | 32.5 | 78 | py |
bottom-up-attention | bottom-up-attention-master/tools/generate_tsv.py | #!/usr/bin/env python
"""Generate bottom-up attention features as a tsv file. Can use multiple gpus, each produces a
separate tsv file that can be merged later (e.g. by using merge_tsv function).
Modify the load_image_ids script as necessary for your data location. """
# Example:
# ./tools/generate_tsv.py -... | 8,584 | 35.688034 | 301 | py |
bottom-up-attention | bottom-up-attention-master/tools/rpn_generate.py | #!/usr/bin/env python
# --------------------------------------------------------
# Fast/er/ R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Generate RPN proposals."""
import _init_... | 2,994 | 31.554348 | 78 | py |
bottom-up-attention | bottom-up-attention-master/tools/train_rfcn_alt_opt_5stage.py | #!/usr/bin/env python
# --------------------------------------------------------
# R-FCN
# Copyright (c) 2016 Yuwen Xiong, Haozhi Qi
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
"""Train a R-FCN network using alternating optimization.
This tool ... | 18,472 | 37.646444 | 103 | py |
bottom-up-attention | bottom-up-attention-master/tools/demo_vg.py | #!/usr/bin/env python
# --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""
Demo script showing detections in sample i... | 11,553 | 34.550769 | 155 | py |
bottom-up-attention | bottom-up-attention-master/tools/train_net.py | #!/usr/bin/env python
# --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Train a Fast R-CNN network on a region of int... | 3,747 | 32.168142 | 78 | py |
bottom-up-attention | bottom-up-attention-master/caffe/tools/extra/summarize.py | #!/usr/bin/env python
"""Net summarization tool.
This tool summarizes the structure of a net in a concise but comprehensive
tabular listing, taking a prototxt file as input.
Use this tool to check at a glance that the computation you've specified is the
computation you expect.
"""
from caffe.proto import caffe_pb2
... | 4,880 | 33.617021 | 95 | py |
bottom-up-attention | bottom-up-attention-master/caffe/tools/extra/parse_log.py | #!/usr/bin/env python
"""
Parse training log
Evolved from parse_log.sh
"""
import os
import re
import extract_seconds
import argparse
import csv
from collections import OrderedDict
def parse_log(path_to_log):
"""Parse log file
Returns (train_dict_list, test_dict_list)
train_dict_list and test_dict_lis... | 7,114 | 32.720379 | 86 | py |
bottom-up-attention | bottom-up-attention-master/caffe/examples/web_demo/app.py | import os
import time
import cPickle
import datetime
import logging
import flask
import werkzeug
import optparse
import tornado.wsgi
import tornado.httpserver
import numpy as np
import pandas as pd
from PIL import Image
import cStringIO as StringIO
import urllib
import exifutil
import caffe
REPO_DIRNAME = os.path.abs... | 7,793 | 33.184211 | 105 | py |
bottom-up-attention | bottom-up-attention-master/caffe/examples/pycaffe/caffenet.py | from __future__ import print_function
from caffe import layers as L, params as P, to_proto
from caffe.proto import caffe_pb2
# helper function for common structures
def conv_relu(bottom, ks, nout, stride=1, pad=0, group=1):
conv = L.Convolution(bottom, kernel_size=ks, stride=stride,
... | 2,112 | 36.732143 | 91 | py |
bottom-up-attention | bottom-up-attention-master/caffe/examples/pycaffe/tools.py | import numpy as np
class SimpleTransformer:
"""
SimpleTransformer is a simple class for preprocessing and deprocessing
images for caffe.
"""
def __init__(self, mean=[128, 128, 128]):
self.mean = np.array(mean, dtype=np.float32)
self.scale = 1.0
def set_mean(self, mean):
... | 3,457 | 27.344262 | 79 | py |
bottom-up-attention | bottom-up-attention-master/caffe/examples/pycaffe/layers/pascal_multilabel_datalayers.py | # imports
import json
import time
import pickle
import scipy.misc
import skimage.io
import caffe
import numpy as np
import os.path as osp
from xml.dom import minidom
from random import shuffle
from threading import Thread
from PIL import Image
from tools import SimpleTransformer
class PascalMultilabelDataLayerSync... | 6,846 | 30.552995 | 78 | py |
bottom-up-attention | bottom-up-attention-master/caffe/examples/pycaffe/layers/pyloss.py | import caffe
import numpy as np
class EuclideanLossLayer(caffe.Layer):
"""
Compute the Euclidean Loss in the same manner as the C++ EuclideanLossLayer
to demonstrate the class interface for developing layers in Python.
"""
def setup(self, bottom, top):
# check input pair
if len(bo... | 1,223 | 31.210526 | 79 | py |
bottom-up-attention | bottom-up-attention-master/caffe/examples/finetune_flickr_style/assemble_data.py | #!/usr/bin/env python
"""
Form a subset of the Flickr Style data, download images to dirname, and write
Caffe ImagesDataLayer training file.
"""
import os
import urllib
import hashlib
import argparse
import numpy as np
import pandas as pd
from skimage import io
import multiprocessing
# Flickr returns a special image i... | 3,636 | 35.737374 | 94 | py |
bottom-up-attention | bottom-up-attention-master/caffe/src/caffe/test/test_data/generate_sample_data.py | """
Generate data used in the HDF5DataLayer and GradientBasedSolver tests.
"""
import os
import numpy as np
import h5py
script_dir = os.path.dirname(os.path.abspath(__file__))
# Generate HDF5DataLayer sample_data.h5
num_cols = 8
num_rows = 10
height = 6
width = 5
total_size = num_cols * num_rows * height * width
da... | 2,104 | 24.670732 | 70 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/draw_net.py | #!/usr/bin/env python
"""
Draw a graph of the net architecture.
"""
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from google.protobuf import text_format
import caffe
import caffe.draw
from caffe.proto import caffe_pb2
def parse_args():
"""Parse input arguments
"""
parser = Argument... | 1,934 | 31.79661 | 81 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/detect.py | #!/usr/bin/env python
"""
detector.py is an out-of-the-box windowed detector
callable from the command line.
By default it configures and runs the Caffe reference ImageNet model.
Note that this model was trained for image classification and not detection,
and finetuning for detection can be expected to improve results... | 5,734 | 31.95977 | 88 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/classify.py | #!/usr/bin/env python
"""
classify.py is an out-of-the-box image classifer callable from the command line.
By default it configures and runs the Caffe reference ImageNet model.
"""
import numpy as np
import os
import sys
import argparse
import glob
import time
import caffe
def main(argv):
pycaffe_dir = os.path.... | 4,262 | 29.669065 | 88 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/train.py | #!/usr/bin/env python
"""
Trains a model using one or more GPUs.
"""
from multiprocessing import Process
import caffe
def train(
solver, # solver proto definition
snapshot, # solver snapshot to restore
gpus, # list of device ids
timing=False, # show timing info for compute and com... | 3,145 | 30.148515 | 85 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/net_spec.py | """Python net specification.
This module provides a way to write nets directly in Python, using a natural,
functional style. See examples/pycaffe/caffenet.py for an example.
Currently this works as a thin wrapper around the Python protobuf interface,
with layers and parameters automatically generated for the "layers"... | 8,048 | 34.45815 | 88 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/classifier.py | #!/usr/bin/env python
"""
Classifier is an image classifier specialization of Net.
"""
import numpy as np
import caffe
class Classifier(caffe.Net):
"""
Classifier extends Net for image class prediction
by scaling, center cropping, or oversampling.
Parameters
----------
image_dims : dimensio... | 3,537 | 34.737374 | 78 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/coord_map.py | """
Determine spatial relationships between layers to relate their coordinates.
Coordinates are mapped from input-to-output (forward), but can
be mapped output-to-input (backward) by the inverse mapping too.
This helps crop and align feature maps among other uses.
"""
from __future__ import division
import numpy as np... | 6,721 | 35.139785 | 79 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/detector.py | #!/usr/bin/env python
"""
Do windowed detection by classifying a number of images/crops at once,
optionally using the selective search window proposal method.
This implementation follows ideas in
Ross Girshick, Jeff Donahue, Trevor Darrell, Jitendra Malik.
Rich feature hierarchies for accurate object detection... | 8,541 | 38.364055 | 80 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/__init__.py | from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
from ._caffe import init_log, log, set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list, set_random_seed, solver_count, set_solver_count, solver_rank, set_solver_rank, set_mul... | 561 | 61.444444 | 225 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/pycaffe.py | """
Wrap the internal caffe C++ module (_caffe.so) with a clean, Pythonic
interface.
"""
from collections import OrderedDict
try:
from itertools import izip_longest
except:
from itertools import zip_longest as izip_longest
import numpy as np
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \... | 11,256 | 32.602985 | 89 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/draw.py | """
Caffe network visualization: draw the NetParameter protobuffer.
.. note::
This requires pydot>=1.0.2, which is not included in requirements.txt since
it requires graphviz and other prerequisites outside the scope of the
Caffe.
"""
from caffe.proto import caffe_pb2
"""
pydot is not supported under p... | 8,813 | 34.97551 | 120 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/io.py | import numpy as np
import skimage.io
from scipy.ndimage import zoom
from skimage.transform import resize
try:
# Python3 will most likely not be able to load protobuf
from caffe.proto import caffe_pb2
except:
import sys
if sys.version_info >= (3, 0):
print("Failed to include caffe_pb2, things mi... | 12,729 | 32.151042 | 110 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/test/test_coord_map.py | import unittest
import numpy as np
import random
import caffe
from caffe import layers as L
from caffe import params as P
from caffe.coord_map import coord_map_from_to, crop
def coord_net_spec(ks=3, stride=1, pad=0, pool=2, dstride=2, dpad=0):
"""
Define net spec for simple conv-pool-deconv pattern common t... | 6,894 | 34.725389 | 79 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/test/test_python_layer_with_param_str.py | import unittest
import tempfile
import os
import six
import caffe
class SimpleParamLayer(caffe.Layer):
"""A layer that just multiplies by the numeric value of its param string"""
def setup(self, bottom, top):
try:
self.value = float(self.param_str)
except ValueError:
... | 2,031 | 31.774194 | 79 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/test/test_io.py | import numpy as np
import unittest
import caffe
class TestBlobProtoToArray(unittest.TestCase):
def test_old_format(self):
data = np.zeros((10,10))
blob = caffe.proto.caffe_pb2.BlobProto()
blob.data.extend(list(data.flatten()))
shape = (1,1,10,10)
blob.num, blob.channels, b... | 1,694 | 28.736842 | 65 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/test/test_solver.py | import unittest
import tempfile
import os
import numpy as np
import six
import caffe
from test_net import simple_net_file
class TestSolver(unittest.TestCase):
def setUp(self):
self.num_output = 13
net_f = simple_net_file(self.num_output)
f = tempfile.NamedTemporaryFile(mode='w+', delete=F... | 2,165 | 33.380952 | 76 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/test/test_layer_type_list.py | import unittest
import caffe
class TestLayerTypeList(unittest.TestCase):
def test_standard_types(self):
#removing 'Data' from list
for type_name in ['Data', 'Convolution', 'InnerProduct']:
self.assertIn(type_name, caffe.layer_type_list(),
'%s not in layer_type_lis... | 338 | 27.25 | 65 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/test/test_net.py | import unittest
import tempfile
import os
import numpy as np
import six
from collections import OrderedDict
import caffe
def simple_net_file(num_output):
"""Make a simple net prototxt, based on test_net.cpp, returning the name
of the (temporary) file."""
f = tempfile.NamedTemporaryFile(mode='w+', delete... | 9,722 | 27.101156 | 78 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/test/test_net_spec.py | import unittest
import tempfile
import caffe
from caffe import layers as L
from caffe import params as P
def lenet(batch_size):
n = caffe.NetSpec()
n.data, n.label = L.DummyData(shape=[dict(dim=[batch_size, 1, 28, 28]),
dict(dim=[batch_size, 1, 1, 1])],
... | 3,287 | 39.097561 | 77 | py |
bottom-up-attention | bottom-up-attention-master/caffe/python/caffe/test/test_python_layer.py | import unittest
import tempfile
import os
import six
import caffe
class SimpleLayer(caffe.Layer):
"""A layer that just multiplies by ten"""
def setup(self, bottom, top):
pass
def reshape(self, bottom, top):
top[0].reshape(*bottom[0].data.shape)
def forward(self, bottom, top):
... | 5,510 | 31.609467 | 81 | py |
bottom-up-attention | bottom-up-attention-master/caffe/scripts/cpp_lint.py | #!/usr/bin/python2
#
# Copyright (c) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of... | 187,450 | 37.49887 | 93 | py |
bottom-up-attention | bottom-up-attention-master/caffe/scripts/split_caffe_proto.py | #!/usr/bin/env python
import mmap
import re
import os
import errno
script_path = os.path.dirname(os.path.realpath(__file__))
# a regex to match the parameter definitions in caffe.proto
r = re.compile(r'(?://.*\n)*message ([^ ]*) \{\n(?: .*\n|\n)*\}')
# create directory to put caffe.proto fragments
try:
os.mkdir(... | 941 | 25.166667 | 65 | py |
bottom-up-attention | bottom-up-attention-master/caffe/scripts/download_model_binary.py | #!/usr/bin/env python
import os
import sys
import time
import yaml
import hashlib
import argparse
from six.moves import urllib
required_keys = ['caffemodel', 'caffemodel_url', 'sha1']
def reporthook(count, block_size, total_size):
"""
From http://blog.moleculea.com/2012/10/04/urlretrieve-progres-indicator/
... | 2,531 | 31.461538 | 78 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.