id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
25,713 | from sys import argv
import json
import os
import subprocess
def support(target):
target.write("\n## 7. SUPPORT\n")
target.write("For more information about SDAccel check the [SDAccel User Guides][]\n\n")
target.write("For questions and to get help on this project or your own projects, visit the [SDAccel F... | null |
25,714 | from sys import argv
import json
import os
import subprocess
def license(target):
target.write("\n## 8. LICENSE AND CONTRIBUTING TO THE REPOSITORY\n")
target.write("The source for this project is licensed under the [3-Clause BSD License][]\n\n")
target.write("To contribute to this project, follow the guide... | null |
25,715 | from sys import argv
import json
import os
import subprocess
def ack(target,data):
target.write("\n## 9. ACKNOWLEDGEMENTS\n")
target.write("This example is written by developers at\n")
for contributor in data["contributors"]:
target.write("- [")
target.write(contributor["group"])
ta... | null |
25,716 | from sys import argv
import json
import os
import subprocess
def dirTraversal(stop_file):
stop_search = None
level_count = 1
s = os.path.join('..', stop_file)
while level_count < 20:
s = os.path.join('..', s)
if os.path.isfile(s):
break
level_count += 1
return lev... | null |
25,717 | import os, re
import fnmatch
import json
def get_immediate_subdirectories(dir):
return [name for name in os.listdir(dir)
if os.path.isdir(os.path.join(dir, name))]
def gen_category(dir ,outfile, subdircount):
links = "[" + dir +"]:"+ dir + "\n"
testcaselist = get_testcases(dir);
for testcase in te... | null |
25,718 | import os, re
import fnmatch
import json
def gen_category(dir ,outfile, subdircount):
links = "[" + dir +"]:"+ dir + "\n"
testcaselist = get_testcases(dir);
for testcase in testcaselist:
drives = get_drives(testcase)
link = ""
if len(drives) <= subdircount :
continue
for drive in drives:
... | null |
25,719 | import os
import json
import collections
import sys
import subprocess
def get_git_root_directory():
# git rev-parse --show-toplevel
p = subprocess.Popen(["git", "rev-parse", "--show-toplevel"], stdout=subprocess.PIPE)
dir = p.communicate()[0].strip()
returncode = p.returncode
if returncode == 0:
... | null |
25,720 | import os
import json
import collections
import sys
import subprocess
def get_git_branch():
branch = subprocess.Popen(["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE).communicate()[0]
# only works on python 2.7+:
#branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "H... | null |
25,721 | import os
import json
import collections
import sys
import subprocess
if len(sys.argv) > 2:
print "Usage: %s [<catalog>.json]" % sys.argv[0]
sys.exit(os.EX_USAGE)
def addexample(path):
example = collections.OrderedDict()
example["name"] = os.path.basename(path)
example["commit_id"] = get_commit_id(p... | null |
25,722 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
def get_json(endpoint, params):
def action(username, apikey, action, job_name=None, job_number=None):
params = {
... | null |
25,723 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
if job_number is not None:
params['number'] = job_number
if job_name is not None:
raise RuntimeError("ERROR: ... | null |
25,724 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
if job_number is not None:
params['number'] = job_number
if job_name is not None:
raise RuntimeError("ERROR: ... | null |
25,725 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
def get_json(endpoint, params):
def connect(username, apikey, job_number=None, job_name=None):
params = {
'userna... | null |
25,726 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
def get_json(endpoint, params):
def info(username, apikey, job_number=None, job_name=None):
params = {
'username'... | null |
25,727 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def get_json(endpoint, params):
try:
ret = get_lines(endpoint, params)
except urllib2.HTTPError as e:
if e.code == 404:
ret = e.read()
pass
else:
raise
if re... | null |
25,728 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
if job_number is not None:
params['number'] = job_number
if job_name is not None:
raise RuntimeError("ERROR: ... | null |
25,729 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
def get_json(endpoint, params):
def status(username, apikey, job_number=None, job_name=None):
params = {
'usernam... | null |
25,730 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
if job_number is not None:
params['number'] = job_number
if job_name is not None:
raise RuntimeError("ERROR: ... | null |
25,731 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def lftp(cmds):
FNULL = open(os.devnull, 'w')
lftp_proc = subprocess.Popen(["lftp"], stderr=FNULL, stdin=subprocess.PIPE)
lftp_proc.communicate(input=cmds)[0]
def upload_t... | null |
25,732 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def lftp(cmds):
FNULL = open(os.devnull, 'w')
lftp_proc = subprocess.Popen(["lftp"], stderr=FNULL, stdin=subprocess.PIPE)
lftp_proc.communicate(input=cmds)[0]
def download... | null |
25,733 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def submit(username, apikey, job_desc):
params = job_desc
user_params = {
'username': username,
'apikey': apikey
}
params["user"] = user_params
ret = post_json("submi... | null |
25,762 | import sys
import os
for i in range (cu_num):
result += genOFM(i,ofm_number)
for i in range (cu_num):
result += genIFM(i,ifm_number)
for i in range (cu_num):
result += genWGT(i,wgt_number,ifm_number*cu_num)
for i in range (cu_num):
result += genSP(i, "INSTR", 1)
result += genSP(i, "BIAS", 1)
res... | null |
25,763 | import sys
import os
for i in range (cu_num):
result += genOFM(i,ofm_number)
for i in range (cu_num):
result += genIFM(i,ifm_number)
for i in range (cu_num):
result += genWGT(i,wgt_number,ifm_number*cu_num)
for i in range (cu_num):
result += genSP(i, "INSTR", 1)
result += genSP(i, "BIAS", 1)
res... | null |
25,764 | import sys
import os
for i in range (cu_num):
result += genOFM(i,ofm_number)
for i in range (cu_num):
result += genIFM(i,ifm_number)
for i in range (cu_num):
result += genWGT(i,wgt_number,ifm_number*cu_num)
for i in range (cu_num):
result += genSP(i, "INSTR", 1)
result += genSP(i, "BIAS", 1)
res... | null |
25,765 | import sys
import os
for i in range (cu_num):
result += genOFM(i,ofm_number)
for i in range (cu_num):
result += genIFM(i,ifm_number)
for i in range (cu_num):
result += genWGT(i,wgt_number,ifm_number*cu_num)
global S_AXI_N
S_AXI_N = 21
for i in range (cu_num):
result += genSP(i, "INSTR", 1)
result +... | null |
25,787 | from sys import argv
import json
import glob
import os
import subprocess
def create_params(target,data):
def add_libs(target, data):
def add_host_flags(target, data):
def add_kernel_flags(target, data):
def add_containers(target, data):
def mk_clean(target, data):
def mk_build_all(target, data):
def mk_check(target, da... | null |
25,800 | from sys import argv
import json
import os
import subprocess
def dirTraversal(stop_file):
def relativeTree(levels):
def footer(target):
relativeLevels = dirTraversal("LICENSE.txt")
root = relativeTree(relativeLevels)
target.write("[3-Clause BSD License]: " + root + "LICENSE.txt\n")
target.write("[SDAcc... | null |
25,805 | import os
import json
import collections
import sys
import subprocess
if len(sys.argv) > 2:
print "Usage: %s [<catalog>.json]" % sys.argv[0]
sys.exit(os.EX_USAGE)
def addexample(path):
index = searchdir(root)
index["branch"] = get_git_branch()
if len(sys.argv) == 2:
index_filename = sys.argv[1]
indexdir... | null |
25,806 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
if job_number is not None:
params['number'] = job_number
if job_name is not None:
raise RuntimeError("ERROR: ... | null |
25,809 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
if job_number is not None:
params['number'] = job_number
if job_name is not None:
raise RuntimeError("ERROR: ... | null |
25,811 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def get_json(endpoint, params):
def jobs(username, apikey):
params = {
'username': username,
'apikey': apikey
}
ret = get_json("jobs", params)
return ret | null |
25,812 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
def get_lines(endpoint, params):
def output(username, apikey, job_number=None, job_name=None, lines=None):
params =... | null |
25,813 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def set_job_name_or_number(params, job_name, job_number):
if job_number is not None:
params['number'] = job_number
if job_name is not None:
raise RuntimeError("ERROR: ... | null |
25,817 | import sys
import optparse
import os
import pwd
import datetime
import time
import subprocess
import json
import urllib2
import urllib
import re
def submit(username, apikey, job_desc):
job = submit_testcase(nimbix_user, nimbix_apikey,
testid, exe, args,
type, nae, tt, dp)
d... | null |
25,820 | import argparse
import numpy as np
import os
The provided code snippet includes necessary dependencies for implementing the `compute_classification_accuracy` function. Write a Python function `def compute_classification_accuracy(results, gts)` to solve the following problem:
Evaluate classification results :param resu... | Evaluate classification results :param results: predicted results :param gts: ground truth :return: accuracy |
25,821 | import argparse
import numpy as np
import os
def voc_ap(rec, prec, use_07_metric=False):
"""
Compute VOC AP given precision and recall.
:param rec: recall
:param prec: precision
:param use_07_metric: uses the VOC 07 11 point method to compute VOC AP given precision and recall
:return: ap
"""... | Evaluate detection results :param results: image_name class_label score xmin ymin xmax ymax :param gts: image_name class_label xmin ymin xmax ymax :param thresh: only bboxes whose confidence score under thresh are used :param overlap_thresh: threshold of IOU ratio to determine a match bbox :param use_07_metric: uses th... |
25,824 | import cv2
import numpy as np
import os
import xir
import argparse
import vitis_ai_library
def get_imagefiles(image_path, batchsize):
files = [f for f in os.listdir(image_path) if f[f.rfind('.'):] in supported_ext]
img_num = len(files)
if (img_num % batchsize > 0):
app_num = batchsize - img_num % ba... | null |
25,835 | import numpy as np
def softmax(res):
x = np.array(res)
x = x.reshape(-1)
e_x = np.exp(x - np.max(x))
res_list = (e_x / e_x.sum(axis=0)).tolist()
return res_list | null |
25,836 | import numpy as np
def sort_idx(res):
sort_idx = np.flip(np.squeeze(np.argsort(res)))
return sort_idx | null |
25,837 | import time
import multiprocessing
import os
from multiprocessing import Process
from multiprocessing import shared_memory
import argparse
import threading
from threading import Lock, Thread
import numpy as np
import demo.input
import demo.onnx
import demo.utils
image_file_path = parser.parse_args().image_file_path
onn... | null |
25,838 | import argparse
import numpy as np
import onnxruntime
import warnings
from PIL import Image, ImageDraw, ImageFont
import numpy as np
def get_batch():
import subprocess
cmd = "xdputil query | grep 'DPU Batch' | awk -F':' '{ print $2}' | awk -F',' '{ print $1}' "
p = subprocess.Popen(cmd, stdout=subprocess.PIPE... | null |
25,839 | import argparse
import numpy as np
import onnxruntime
import warnings
from PIL import Image, ImageDraw, ImageFont
import numpy as np
def softmax(res):
x = np.array(res)
x = x.reshape(-1)
e_x = np.exp(x - np.max(x))
res_list = (e_x / e_x.sum(axis=0)).tolist()
return res_list | null |
25,840 | import argparse
import numpy as np
import onnxruntime
import warnings
from PIL import Image, ImageDraw, ImageFont
import numpy as np
def sort_idx(res):
return np.flip(np.squeeze(np.argsort(res))) | null |
25,844 | import os
import sys
import logging
from utils import utilities, benchmark_argparser, benchmark_runner, query, summary
def get_running_thread(cu_number, batch_number):
# get the benchmark default run thread
if cu_number > 1:
default_thread = cu_number * 2
logging.debug('Benchmark default runnin... | null |
25,845 | import os
import subprocess
import sys
import json
import logging
import logging as _logging
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN
from logging import NOTSET
def execute_cmd(cmd, shell=True, stdout=subprocess.PIPE, stderr=subpro... | null |
25,846 | import os
import subprocess
import sys
import json
import logging
def file_exists(file_path):
return True if os.path.exists(file_path) else False | null |
25,847 | import os
import subprocess
import sys
import json
import logging
import logging as _logging
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN
from logging import NOTSET
def makedirs(dir_path):
try:
os.makedirs(dir_path)
exc... | null |
25,848 | import os
import subprocess
import sys
import json
import logging
import logging as _logging
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN
from logging import NOTSET
def rmdir(dir_path):
try:
import shutil
shutil.rmt... | null |
25,849 | import os
import subprocess
import sys
import json
import logging
import logging as _logging
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN
from logging import NOTSET
def read_json_to_dict(file_path):
try:
if not os.path.exis... | null |
25,850 | import os
import subprocess
import sys
import json
import logging
import logging as _logging
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN
from logging import NOTSET
def save_dict_to_json(result_file, results):
try:
logging.... | null |
25,851 | import os
import subprocess
import sys
import json
import logging
import logging as _logging
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN
from logging import NOTSET
def read_file(file_path):
try:
if not os.path.exists(file_... | null |
25,852 | import os
import subprocess
import sys
import json
import logging
import logging as _logging
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN
from logging import NOTSET
def set_env(env_dict):
for key, value in env_dict.items():
... | null |
25,853 | from typing import List
import cv2
import numpy as np
import sys
import math
import xir
import vitis_ai_library
def resize_shortest_edge(image, smallest_side):
def crop_image(image, height, width):
def preprocess_one_image(image_path, width, height, means, scales, fixpos):
image = cv2.imread(image_path)
image ... | null |
25,855 | import os, sys
import json
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow_model_optimization.quantization.keras import vitis_quantize
The provided code snippet includes necessary dependencies for implementing the `load_json` function. Write a Python function `def load_json(json... | Load json file. |
25,856 | import os, sys
import json
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow_model_optimization.quantization.keras import vitis_quantize
class PRelu(tf.keras.layers.Layer):
"""
single input and single output custom op with weights
"""
def __init__(self, name="param_relu", *... | null |
25,857 | import gzip
import numpy as np
import os
import tensorflow
from tensorflow.keras import backend as K
from tensorflow.keras import layers
import tensorflow as tf
data_dir = './dataset'
if os.path.exists(data_dir):
print('**********************load_data')
(x_train, y_train), (x_test, y_test) = load_data()
else:
pri... | null |
25,858 | import gzip
import numpy as np
import os
import tensorflow
from tensorflow.keras import backend as K
from tensorflow.keras import layers
import tensorflow as tf
tf.config.run_functions_eagerly(True)
def net_fn():
tf.config.run_functions_eagerly(True)
if K.image_data_format() == 'channels_first':
inputs = tf.ker... | null |
25,859 | import gzip
import numpy as np
import os
import tensorflow
from tensorflow.keras import backend as K
from tensorflow.keras import layers
import tensorflow as tf
x_test = x_test.astype('float32')
x_test
tf.config.run_functions_eagerly(True)
def eval_input_fn():
return tf.estimator.inputs.numpy_input_fn(
x={"inp... | null |
25,862 | import os, sys
import json
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow_model_optimization.quantization.keras import vitis_quantize
def build_model():
inputs = tf.keras.Input((28, 28, 1))
x = tf.keras.layers.Conv2D(32, (7, 7))(inputs)
x = tf.keras.layers.BatchNormalizat... | null |
25,892 | import argparse
import os
import random
import shutil
import time
import warnings
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.multiprocessing as mp
import torch.utils.data
import torch.utils.data.distri... | null |
25,900 | import argparse
import os
import time
import torch
import torchvision.datasets as datasets
from torchvision.models.resnet import resnet18
import torchvision.transforms as transforms
from pytorch_nndct import get_pruning_runner
class AverageMeter(object):
"""Computes and stores the average and current value"""
def _... | null |
25,902 | import argparse
import os
import time
import torch
import torch.nn as nn
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from pytorch_nndct import get_pruning_runner
class AverageMeter(object):
def __init__(self, name, fmt=':f'):
def reset(self):
def update(self, val, ... | null |
25,909 | import argparse
import os
import shutil
import time
import torch
import torchvision
import torchvision.datasets as datasets
import torchvision.transforms as transforms
import torch.nn as nn
from pytorch_nndct.nn.modules import functional
from pytorch_nndct.quantization import bfp
class Bottleneck(nn.Module):
expansio... | null |
25,915 | import os
import re
import sys
import argparse
import time
import pdb
import random
from pytorch_nndct.apis import torch_quantizer
import torch
import torchvision
import torchvision.transforms as transforms
from torchvision.models.resnet import resnet18
from tqdm import tqdm
device = torch.device("cuda" if torch.cuda.i... | null |
25,933 | from torch import Tensor, nn
import torch
import numpy as np
from pytorch_nndct.expanding.structured import ExpandingRunner
from torchvision.models.resnet import resnet18, resnet34, resnet50, resnet152
from torchvision.models.inception import inception_v3
import argparse
args, _ = parser.parse_known_args()
def do_expan... | null |
25,939 | from pytorch_nndct.expanding.expanding_lib import expand_and_export, load_expanded_model
from torchvision.models.inception import inception_v3
import torch
from torch import nn
import os
import onnxruntime
import argparse
import numpy as np
model = inception_v3(init_weights=True).eval()
input_signature = torch.rand((1,... | null |
25,953 |
def execute_async( inputs, outputs):
pass | null |
25,954 |
def create_runner(subgraph, mode):
pass | null |
25,955 |
def create_graph_runner( graph):
pass | null |
25,956 |
def get_inputs():
pass | null |
25,957 |
def wait(jobid_time):
pass | null |
25,958 |
def get_output_tensors():
pass | null |
25,959 |
def get_outputs():
pass | null |
25,960 |
def get_input_tensors():
pass | null |
25,961 | import os
import sys
import recommonmark
from recommonmark.transform import AutoStructify
from recommonmark.parser import CommonMarkParser
from datetime import date
def setup(app):
app.add_css_file('custom.css') | null |
25,962 | import os
import sys
import recommonmark
from recommonmark.transform import AutoStructify
from recommonmark.parser import CommonMarkParser
from datetime import date
def setup(app):
app.add_config_value('recommonmark_config', {
'url_resolver': lambda url: github_doc_root + url,
'auto_toc_tre... | null |
25,963 | import os
import argparse
import numpy as np
import time
import pyxir
import tvm
from tvm.contrib import graph_executor
from PIL import Image
from tvm.contrib.download import download_testdata
img_path = download_testdata(img_url, 'cat.png', module='data')
with open(synset_path) as f:
synset = eval(f.read())
def tr... | null |
25,964 | import os
import time
import argparse
import numpy as np
import threading
import multiprocessing as mp
import pyxir
import tvm
from tvm.contrib import graph_executor
from PIL import Image
from tvm.contrib.download import download_testdata
def transform_image(image):
image = np.array(image) - np.array([123., 117., ... | null |
25,965 | import os
import time
import argparse
import numpy as np
import threading
import multiprocessing as mp
import pyxir
import tvm
from tvm.contrib import graph_executor
from PIL import Image
from tvm.contrib.download import download_testdata
def softmax(x):
x_exp = np.exp(x - np.max(x))
return x_e... | null |
25,966 | import os
import time
import argparse
import numpy as np
import threading
import multiprocessing as mp
import pyxir
import tvm
from tvm.contrib import graph_executor
from PIL import Image
from tvm.contrib.download import download_testdata
def run(mod, nb_images, inputs):
for _ in range(nb_images):
for name... | null |
25,967 | import os
import sys
import numpy as np
import cv2
import time
from typing import List
from pathlib import Path
import pyxir
import pyxir.contrib.target.DPUCADF8H
import pyxir.contrib.target.DPUCAHX8H
import pyxir.contrib.target.DPUCAHX8L
import pyxir.contrib.target.DPUCVDX8H
import pyxir.contrib.target.DPUCZDX8G
impor... | null |
25,968 | import os, sys
import argparse
import numpy as np
import time
import cv2
import pyxir
import tvm
from tvm.contrib import graph_executor
def transform_image(image):
"""Data preprocessing function"""
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB).astype(np.float32)
ih, iw = (320, 320)
h, w, _ = image... | null |
25,969 | import os
import random
import cv2
import torch
import numpy as np
from torch.utils.data import Dataset
The provided code snippet includes necessary dependencies for implementing the `transform` function. Write a Python function `def transform(image)` to solve the following problem:
Transform a image by cv2.
Here is ... | Transform a image by cv2. |
25,970 | from torch.nn import Linear, Conv2d, BatchNorm1d, BatchNorm2d, PReLU, ReLU, Sigmoid, Dropout2d, Dropout, AvgPool2d, MaxPool2d, AdaptiveAvgPool2d, Sequential, Module, Parameter
import torch.nn.functional as F
import torch
from collections import namedtuple
def get_block(in_channel, depth, num_units, stride = 2):
retur... | null |
25,971 | import os
import logging
import functools
import numpy as np
import torch
import torch.nn as nn
import torch._utils
import torch.nn.functional as F
from torch.nn import Sequential, Module, Linear, BatchNorm1d
The provided code snippet includes necessary dependencies for implementing the `conv3x3` function. Write a Pyt... | 3x3 convolution with padding |
25,972 | import os
import logging
import functools
import numpy as np
import torch
import torch.nn as nn
import torch._utils
import torch.nn.functional as F
from torch.nn import Sequential, Module, Linear, BatchNorm1d
class HighResolutionNet(nn.Module):
def __init__(self, cfg, **kwargs):
super(HighResolutionNet, sel... | null |
25,973 | import torch
import torch.nn as nn
from math import ceil
def swish_fwd(x):
return x.mul(torch.sigmoid(x)) | null |
25,974 | import torch
import torch.nn as nn
from math import ceil
def swish_bwd(x, grad_output):
x_sigmoid = torch.sigmoid(x)
return grad_output * (x_sigmoid * (1. + x * (1. - x_sigmoid))) | null |
25,975 | import torch
import torch.nn as nn
from math import ceil
if USE_MEMORY_EFFICIENT_SWISH:
class SwishJitImplementation(torch.autograd.Function):
def forward(ctx, x):
ctx.save_for_backward(x)
return swish_fwd(x)
def backward(ctx, grad_output):
x = ctx.saved_tensors[0... | null |
25,976 | import torch
import torch.nn as nn
from math import ceil
def swish(x, inplace=False):
return x.mul_(x.sigmoid()) if inplace else x.mul(x.sigmoid()) | null |
25,977 | import torch
import torch.nn as nn
from math import ceil
def ConvBNAct(out, in_channels, channels, kernel=1, stride=1, pad=0,
num_group=1, active=True, relu6=False):
out.append(nn.Conv2d(in_channels, channels, kernel,
stride, pad, groups=num_group, bias=False))
out.append... | null |
25,978 | import torch
import torch.nn as nn
from math import ceil
class Swish(nn.Module):
def __init__(self, inplace=True):
super(Swish, self).__init__()
self.inplace = inplace
def forward(self, x):
return swish(x, self.inplace)
def ConvBNSwish(out, in_channels, channels, kernel=1, stride=1, pad... | null |
25,979 | import re
import math
import collections
from functools import partial
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils import model_zoo
from torch.nn import Sequential, BatchNorm1d, BatchNorm2d, Dropout, Module, Linear
The provided code snippet includes necessary dependencies fo... | Calculate and round number of filters based on width multiplier. Use width_coefficient, depth_divisor and min_depth of global_params. Args: filters (int): Filters number to be calculated. global_params (namedtuple): Global params of the model. Returns: new_filters: New filters number after calculating. |
25,980 | import re
import math
import collections
from functools import partial
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils import model_zoo
from torch.nn import Sequential, BatchNorm1d, BatchNorm2d, Dropout, Module, Linear
The provided code snippet includes necessary dependencies fo... | Calculate module's repeat number of a block based on depth multiplier. Use depth_coefficient of global_params. Args: repeats (int): num_repeat to be calculated. global_params (namedtuple): Global params of the model. Returns: new repeat: New repeat number after calculating. |
25,981 | import re
import math
import collections
from functools import partial
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils import model_zoo
from torch.nn import Sequential, BatchNorm1d, BatchNorm2d, Dropout, Module, Linear
The provided code snippet includes necessary dependencies fo... | Drop connect. Args: input (tensor: BCWH): Input of this structure. p (float: 0.0~1.0): Probability of drop connection. training (bool): The running mode. Returns: output: Output after drop connection. |
25,982 | import re
import math
import collections
from functools import partial
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils import model_zoo
from torch.nn import Sequential, BatchNorm1d, BatchNorm2d, Dropout, Module, Linear
def get_width_and_height_from_size(x):
"""Obtain height a... | Calculates the output image size when using Conv2dSamePadding with a stride. Necessary for static padding. Thanks to mannatsingh for pointing this out. Args: input_image_size (int, tuple or list): Size of input image. stride (int, tuple or list): Conv2d operation's stride. Returns: output_image_size: A list [H,W]. |
25,983 | import re
import math
import collections
from functools import partial
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils import model_zoo
from torch.nn import Sequential, BatchNorm1d, BatchNorm2d, Dropout, Module, Linear
class Conv2dDynamicSamePadding(nn.Conv2d):
"""2D Convolut... | Chooses static padding if you have specified an image size, and dynamic padding otherwise. Static padding is necessary for ONNX exporting of models. Args: image_size (int or tuple): Size of the image. Returns: Conv2dDynamicSamePadding or Conv2dStaticSamePadding. |
25,984 | import re
import math
import collections
from functools import partial
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils import model_zoo
from torch.nn import Sequential, BatchNorm1d, BatchNorm2d, Dropout, Module, Linear
class MaxPool2dDynamicSamePadding(nn.MaxPool2d):
"""2D Ma... | Chooses static padding if you have specified an image size, and dynamic padding otherwise. Static padding is necessary for ONNX exporting of models. Args: image_size (int or tuple): Size of the image. Returns: MaxPool2dDynamicSamePadding or MaxPool2dStaticSamePadding. |
25,985 | import re
import math
import collections
from functools import partial
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils import model_zoo
from torch.nn import Sequential, BatchNorm1d, BatchNorm2d, Dropout, Module, Linear
def efficientnet_params(model_name):
"""Map EfficientNet ... | Get the block args and global params for a given model name. Args: model_name (str): Model's name. override_params (dict): A dict to modify global_params. Returns: blocks_args, global_params |
25,986 | import re
import math
import collections
from functools import partial
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils import model_zoo
from torch.nn import Sequential, BatchNorm1d, BatchNorm2d, Dropout, Module, Linear
url_map = {
'efficientnet-b0': 'https://github.com/lukeme... | Loads pretrained weights from weights path or download using url. Args: model (Module): The whole model of efficientnet. model_name (str): Model name of efficientnet. weights_path (None or str): str: path to pretrained weights file on the local disk. None: use pretrained weights downloaded from the Internet. load_fc (b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.