id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
30,303 | import paddle
import paddle.nn as nn
from paddle.utils.download import get_weights_path_from_url
class BasicBlock(nn.Layer):
'''
basic block
'''
expansion = 1
def __init__(self,
inplanes,
planes,
stride=1,
downsample=None,
... | build ResNet18 |
30,304 | import paddle
import paddle.nn as nn
from paddle.utils.download import get_weights_path_from_url
class BasicBlock(nn.Layer):
'''
basic block
'''
expansion = 1
def __init__(self,
inplanes,
planes,
stride=1,
downsample=None,
... | build ResNet34 |
30,305 | import paddle
import paddle.nn as nn
from paddle.utils.download import get_weights_path_from_url
class BottleneckBlock(nn.Layer):
'''
bottleneck block
'''
expansion = 4
def __init__(self,
inplanes,
planes,
stride=1,
downsample=None,... | build ResNet101 |
30,306 | import paddle
import paddle.nn as nn
from paddle.utils.download import get_weights_path_from_url
class BottleneckBlock(nn.Layer):
'''
bottleneck block
'''
expansion = 4
def __init__(self,
inplanes,
planes,
stride=1,
downsample=None,... | build ResNet152 |
30,311 | import paddle
The provided code snippet includes necessary dependencies for implementing the `interpolate_position_embedding` function. Write a Python function `def interpolate_position_embedding(model, state_dict)` to solve the following problem:
interpolate pos embed from model state for new model
Here is the funct... | interpolate pos embed from model state for new model |
30,312 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,313 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,318 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
30,319 | import os
import numpy as np
import paddle
import torch
import timm
from pvtv2 import build_pvtv2 as build_model
from pvtv2_torch import pvt_v2_b0
from pvtv2_torch import pvt_v2_b1
from pvtv2_torch import pvt_v2_b2
from pvtv2_torch import pvt_v2_b3
from pvtv2_torch import pvt_v2_b4
from pvtv2_torch import pvt_v2_b5
fro... | null |
30,320 | import os
import numpy as np
import paddle
import torch
import timm
from pvtv2 import build_pvtv2 as build_model
from pvtv2_torch import pvt_v2_b0
from pvtv2_torch import pvt_v2_b1
from pvtv2_torch import pvt_v2_b2
from pvtv2_torch import pvt_v2_b3
from pvtv2_torch import pvt_v2_b4
from pvtv2_torch import pvt_v2_b5
fro... | null |
30,321 | import os
import numpy as np
import paddle
import torch
import timm
from pvtv2 import build_pvtv2 as build_model
from pvtv2_torch import pvt_v2_b0
from pvtv2_torch import pvt_v2_b1
from pvtv2_torch import pvt_v2_b2
from pvtv2_torch import pvt_v2_b3
from pvtv2_torch import pvt_v2_b4
from pvtv2_torch import pvt_v2_b5
fro... | null |
30,359 | import copy
import paddle
import paddle.nn as nn
from droppath import DropPath
class PyramidVisionTransformerV2(nn.Layer):
"""PyramidVisionTransformerV2 class
Attributes:
patch_size: int, size of patch
image_size: int, size of image
num_classes: int, num of image classes
in_chann... | build pvtv2 model from config |
30,364 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,365 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,370 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
30,371 | import os
import numpy as np
import paddle
import torch
import timm
from VisionPermutator.models.vip import *
from vip import build_vip as build_model
from config import get_config
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
... | null |
30,372 | import os
import numpy as np
import paddle
import torch
import timm
from VisionPermutator.models.vip import *
from vip import build_vip as build_model
from config import get_config
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
... | null |
30,373 | import os
import numpy as np
import paddle
import torch
import timm
from VisionPermutator.models.vip import *
from vip import build_vip as build_model
from config import get_config
def torch_to_paddle_mapping(model_name, config):
mapping = [
('patch_embed.proj', 'patch_embed.proj'),
]
layer_depth = ... | null |
30,411 | import paddle.nn as nn
import paddle.nn.functional as F
from droppath import DropPath
class WeightedPermuteMLP(nn.Layer):
def __init__(self,
dim,
segment_dim=8,
qkv_bias=False,
qk_scale=None,
attn_drop=0.0,
... | null |
30,412 | import paddle.nn as nn
import paddle.nn.functional as F
from droppath import DropPath
class WeightedPermuteMLP(nn.Layer):
def __init__(self,
dim,
segment_dim=8,
qkv_bias=False,
qk_scale=None,
attn_drop=0.0,
proj_dr... | build vip model using config |
30,417 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,418 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,422 | import os
from yacs.config import CfgNode as CN
import yaml
def _update_config_from_file(config, cfg_file):
"""Load cfg file (.yaml) and update config object
Args:
config: config object
cfg_file: config file (.yaml)
Return:
None
"""
config.defrost()
with open(cfg_file, 'r... | Update config by ArgumentParser Configs that are often used can be updated from arguments Args: args: ArgumentParser contains options Return: config: updated config |
30,423 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
30,424 | import os
import numpy as np
import paddle
import torch
import timm
from topformer import build_topformer as build_model
from config import get_config
from pth_topformer_cls import Topformer
import pth_cfg
def print_model_named_params(model):
print('----------------------------------')
for name, param in model... | null |
30,425 | import os
import numpy as np
import paddle
import torch
import timm
from topformer import build_topformer as build_model
from config import get_config
from pth_topformer_cls import Topformer
import pth_cfg
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in mode... | null |
30,426 | import os
import numpy as np
import paddle
import torch
import timm
from topformer import build_topformer as build_model
from config import get_config
from pth_topformer_cls import Topformer
import pth_cfg
def torch_to_paddle_mapping(model_name, config):
mapping = [
('tpm.stem.0.c', 'tpm.stem.conv'),
... | null |
30,464 | import paddle
import paddle.nn as nn
from droppath import DropPath
The provided code snippet includes necessary dependencies for implementing the `_make_divisible` function. Write a Python function `def _make_divisible(v, divisor, min_value=None)` to solve the following problem:
This function is taken from the origina... | This function is taken from the original tf repo. It ensures that all layers have a channel number that is divisible by 8 It can be seen here: https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py :param v: :param divisor: :param min_value: :return: |
30,465 | import paddle
import paddle.nn as nn
from droppath import DropPath
class Topformer(nn.Layer):
def __init__(self,
cfgs,
channels,
out_channels,
embed_out_indice,
decode_out_indices=[1, 2, 3],
depth=4,
... | Build TopFormer by reading options in config object Args: config: config instance contains setting options Returns: model: nn.Layer, TopFormer model |
30,466 | import paddle
from paddle import nn
from baseconv import Stem, BottleNeck, PointWiseConv, DepthWiseConv
from droppath import DropPath
from attention import MLP, Attention
class MobileFormer(nn.Layer):
"""MobileFormer
Params Info:
num_classes: the number of classes
in_channels: the nu... | null |
30,471 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,472 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,477 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DATA.NUM_... | Return a clone of config and optionally overwrite it from yaml file |
30,518 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,519 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,520 | import os
import math
from paddle.io import Dataset
from paddle.io import DataLoader
from paddle.io import DistributedBatchSampler
from paddle.vision import transforms
from paddle.vision import image_load
class ImageNet2012Dataset(Dataset):
"""Build ImageNet2012 dataset
This class gets train/val imagenet datase... | Get dataset from config and mode (train/val) Returns the related dataset object according to configs and mode(train/val) Args: config: configs contains dataset related settings. see config.py for details is_train: bool, set True to use training set, otherwise val set. Default: True Returns: dataset: dataset object |
30,521 | import os
import math
from paddle.io import Dataset
from paddle.io import DataLoader
from paddle.io import DistributedBatchSampler
from paddle.vision import transforms
from paddle.vision import image_load
The provided code snippet includes necessary dependencies for implementing the `get_dataloader` function. Write a ... | Get dataloader from dataset, allows multiGPU settings. Multi-GPU loader is implements as distributedBatchSampler. Args: config: see config.py for details dataset: paddle.io.dataset object is_train: bool, when False, shuffle is off and BATCH_SIZE_EVAL is used, default: True use_dist_sampler: if True, DistributedBatchSam... |
30,522 | import paddle
import paddle.nn as nn
class VisionTransformer(nn.Layer):
"""ViT transformer
ViT Transformer, classifier is a single Linear layer for finetune,
For training from scratch, two layer mlp should be used.
Classification is done using cls_token.
Args:
image_size: int, input image si... | build vit model from config |
30,524 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
30,525 | import os
import numpy as np
import paddle
import torch
import timm
from vit import build_vit
from config import get_config
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
print(name, param.shape)
print('-----------------... | null |
30,526 | import os
import numpy as np
import paddle
import torch
import timm
from vit import build_vit
from config import get_config
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
print(name, param.shape)
print('-------------------... | null |
30,527 | import os
import numpy as np
import paddle
import torch
import timm
from vit import build_vit
from config import get_config
def torch_to_paddle_mapping(model_name):
def convert(torch_model, paddle_model, model_name):
def _set_value(th_name, pd_name, transpose=True):
th_shape = th_params[th_name].shape
... | null |
30,532 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,533 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,537 | import numpy as np
import paddle
import paddle.nn as nn
from droppath import DropPath
class ShuffleTransformer(nn.Layer):
"""Shuffle Transformer
Args:
image_size: int, input image size, default: 224
num_classes: int, num of classes, default: 1000
token_dim: int, intermediate feature dim ... | build shuffle transformer using config |
30,539 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
30,540 | import os
import numpy as np
import paddle
import torch
import timm
from config import get_config
from shuffle_transformer import build_shuffle_transformer as build_model
from shuffle_transformer_torch import ShuffleTransformer as ShuffleTransformerTorch
def print_model_named_params(model):
print('----------------... | null |
30,541 | import os
import numpy as np
import paddle
import torch
import timm
from config import get_config
from shuffle_transformer import build_shuffle_transformer as build_model
from shuffle_transformer_torch import ShuffleTransformer as ShuffleTransformerTorch
def print_model_named_buffers(model):
print('---------------... | null |
30,542 | import os
import numpy as np
import paddle
import torch
import timm
from config import get_config
from shuffle_transformer import build_shuffle_transformer as build_model
from shuffle_transformer_torch import ShuffleTransformer as ShuffleTransformerTorch
def torch_to_paddle_mapping(model_name, config):
# (torch_param... | null |
30,580 | import math
import copy
from functools import partial
import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from droppath import DropPath
class Beit(nn.Layer):
"""Beit Layer"""
def __init__(self,
img_size=224,
patch_size=16,
in_chans=3,
... | build beit from config |
30,581 | import logging
import sys
import os
import math
import random
from PIL import Image
import paddle
import paddle.nn.functional as F
import paddle.distributed as dist
The provided code snippet includes necessary dependencies for implementing the `get_logger` function. Write a Python function `def get_logger(file_path)` ... | Set logging file and format, logs are written in 2 loggers, one local_logger records the information on its own gpu/process, one master_logger records the overall/average information over all gpus/processes. Args: file_path: str, folder path of the logger files to write Return: local_logger: python logger for each proc... |
30,582 | import logging
import sys
import os
import math
import random
from PIL import Image
import paddle
import paddle.nn.functional as F
import paddle.distributed as dist
The provided code snippet includes necessary dependencies for implementing the `write_log` function. Write a Python function `def write_log(local_logger, ... | Write messages in loggers Args: local_logger: python logger, logs information on single gpu master_logger: python logger, logs information over all gpus msg_local: str, message to log on local_logger msg_master: str, message to log on master_logger, if None, use msg_local, default: None level: str, log level, in ['info... |
30,583 | import logging
import sys
import os
import math
import random
from PIL import Image
import paddle
import paddle.nn.functional as F
import paddle.distributed as dist
The provided code snippet includes necessary dependencies for implementing the `all_reduce_mean` function. Write a Python function `def all_reduce_mean(x)... | perform all_reduce on Tensor for gathering results from multi-gpus |
30,584 | import logging
import sys
import os
import math
import random
from PIL import Image
import paddle
import paddle.nn.functional as F
import paddle.distributed as dist
The provided code snippet includes necessary dependencies for implementing the `skip_weight_decay_fn` function. Write a Python function `def skip_weight_d... | Set params with no weight decay during the training For certain params, e.g., positional encoding in ViT, weight decay may not needed during the learning, this method is used to find these params. Args: model: nn.Layer, model skip_list: list, a list of params names which need to exclude from weight decay, default: [] f... |
30,585 | import logging
import sys
import os
import math
import random
from PIL import Image
import paddle
import paddle.nn.functional as F
import paddle.distributed as dist
def cosine_scheduler(base_value,
final_value,
epochs,
num_iters_per_epoch,
... | null |
30,586 | import logging
import sys
import os
import math
import random
from PIL import Image
import paddle
import paddle.nn.functional as F
import paddle.distributed as dist
def _pil_interp(method):
if method == 'bicubic':
return Image.BICUBIC
elif method == 'lanczos':
return Image.LANCZOS
elif meth... | null |
30,587 | import numpy as np
import paddle.inference as paddle_infer
from paddle.vision import image_load
from paddle.vision import transforms
The provided code snippet includes necessary dependencies for implementing the `load_img` function. Write a Python function `def load_img(img_path, sz=224)` to solve the following proble... | load image and apply transforms |
30,588 | import paddle
The provided code snippet includes necessary dependencies for implementing the `interpolate_position_embedding` function. Write a Python function `def interpolate_position_embedding(model, state_dict)` to solve the following problem:
interpolate pos embed from model state for new model, This version is f... | interpolate pos embed from model state for new model, This version is for BeiT |
30,589 | import paddle
logit_laplace_eps = 0.1
def unmap_pixels(x):
if len(x.shape) != 4:
raise ValueError('expected input to be 4d')
if x.dtype != paddle.float32:
raise ValueError('expected input to have type float32')
return torch.clamp((x - logit_laplace_eps) / (1 - 2 * logit_laplace_eps), 0, 1) | null |
30,590 | import os
import math
from paddle.io import Dataset
from paddle.io import DataLoader
from paddle.io import DistributedBatchSampler
from paddle.vision import transforms
from paddle.vision import image_load
from augment import auto_augment_policy_original
from augment import AutoAugment
from augment import rand_augment_p... | Get training transforms For training, a RandomResizedCrop is applied with random mirror, then normalization is applied with mean and std. The input pixel values must be rescaled to [0, 1.]. Outputs is converted to tensor. Args: config: configs contains IMAGE_SIZE, see config.py for details Returns: transforms_train: tr... |
30,591 | import os
import math
from paddle.io import Dataset
from paddle.io import DataLoader
from paddle.io import DistributedBatchSampler
from paddle.vision import transforms
from paddle.vision import image_load
from augment import auto_augment_policy_original
from augment import AutoAugment
from augment import rand_augment_p... | Get transforms for beit pretraining For training, a RandomResizedCrop is applied with random mirror, then RandAug, AutoAug or ColorJitter is applied, then normalization is applied with mean and std, and RandomErase is applied. The input pixel values must be rescaled to [0, 1.]. Outputs is converted to tensor. Args: con... |
30,592 | import os
import math
from paddle.io import Dataset
from paddle.io import DataLoader
from paddle.io import DistributedBatchSampler
from paddle.vision import transforms
from paddle.vision import image_load
from augment import auto_augment_policy_original
from augment import AutoAugment
from augment import rand_augment_p... | Get dataset from config and mode (train/val) Returns the related dataset object according to configs and mode(train/val) Args: config: configs contains dataset related settings. see config.py for details is_train: bool, set True to use training set, otherwise val set. Default: True Returns: dataset: dataset object |
30,593 | import os
import math
from paddle.io import Dataset
from paddle.io import DataLoader
from paddle.io import DistributedBatchSampler
from paddle.vision import transforms
from paddle.vision import image_load
from augment import auto_augment_policy_original
from augment import AutoAugment
from augment import rand_augment_p... | Get dataloader from dataset, allows multiGPU settings. Multi-GPU loader is implements as distributedBatchSampler. Args: config: see config.py for details dataset: paddle.io.dataset object is_train: bool, when False, shuffle is off and BATCH_SIZE_EVAL is used, default: True use_dist_sampler: if True, DistributedBatchSam... |
30,595 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.SECOND_IMAGE_SIZE = 112
_C.DATA.IMAGE_CHANNELS = 3 ... | Return a clone of config and optionally overwrite it from yaml file |
30,596 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,597 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,598 | import os
import numpy as np
import paddle
import torch
import timm
from beit import build_beit as build_model
from config import get_config
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
print(name, param.shape)
print('... | null |
30,599 | import os
import numpy as np
import paddle
import torch
import timm
from beit import build_beit as build_model
from config import get_config
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
print(name, param.shape)
print('--... | null |
30,600 | import os
import numpy as np
import paddle
import torch
import timm
from beit import build_beit as build_model
from config import get_config
def torch_to_paddle_mapping(model_name, config):
mapping = [
('cls_token', 'cls_token'),
('patch_embed.proj', 'patch_embed.proj'),
]
num_layers = confi... | null |
30,638 | import os
import math
import paddle
import paddle.nn as nn
from paddle import Tensor
from paddle.vision.ops import deform_conv2d
import paddle.nn.functional as F
from droppath import DropPath
class CycleMLP(nn.Layer):
def __init__(self,
dim,
qkv_bias=False,
qk_scal... | null |
30,639 | import os
import math
import paddle
import paddle.nn as nn
from paddle import Tensor
from paddle.vision.ops import deform_conv2d
import paddle.nn.functional as F
from droppath import DropPath
class CycleMLP(nn.Layer):
def __init__(self,
dim,
qkv_bias=False,
qk_scal... | build cyclemlp model |
30,644 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,645 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,650 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
30,651 | import os
import numpy as np
import paddle
import torch
import timm
from cyclemlp import build_cyclemlp as build_model
from config import get_config
from cyclemlp_torch import CycleMLP_B1
from cyclemlp_torch import CycleMLP_B2
from cyclemlp_torch import CycleMLP_B3
from cyclemlp_torch import CycleMLP_B4
from cyclemlp_t... | null |
30,652 | import os
import numpy as np
import paddle
import torch
import timm
from cyclemlp import build_cyclemlp as build_model
from config import get_config
from cyclemlp_torch import CycleMLP_B1
from cyclemlp_torch import CycleMLP_B2
from cyclemlp_torch import CycleMLP_B3
from cyclemlp_torch import CycleMLP_B4
from cyclemlp_t... | null |
30,653 | import os
import numpy as np
import paddle
import torch
import timm
from cyclemlp import build_cyclemlp as build_model
from config import get_config
from cyclemlp_torch import CycleMLP_B1
from cyclemlp_torch import CycleMLP_B2
from cyclemlp_torch import CycleMLP_B3
from cyclemlp_torch import CycleMLP_B4
from cyclemlp_t... | null |
30,691 | import os
import numpy as np
import paddle
import torch
import timm
from rest_v2 import build_restv2 as build_model
from config import get_config
from pth_rest_v2 import *
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
print... | null |
30,692 | import os
import numpy as np
import paddle
import torch
import timm
from rest_v2 import build_restv2 as build_model
from config import get_config
from pth_rest_v2 import *
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
print(n... | null |
30,693 | import os
import numpy as np
import paddle
import torch
import timm
from rest_v2 import build_restv2 as build_model
from config import get_config
from pth_rest_v2 import *
def torch_to_paddle_mapping(model_name, config):
def convert(torch_model, paddle_model, model_name, config):
def _set_value(th_name, pd_name, t... | null |
30,694 | import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from droppath import DropPath
class ResT(nn.Layer):
def __init__(self,
in_channels=3,
num_classes=1000,
embed_dims=[64, 128, 256, 512],
num_heads=[1, 2, 4, 8],
m... | build rest model from config |
30,695 | import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from droppath import DropPath
class ResTV2(nn.Layer):
def __init__(self,
in_channels=3,
num_classes=1000,
embed_dims=[96, 192, 384, 768],
num_heads=[1, 2, 4, 8],
... | build rest model from config |
30,700 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,701 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,706 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
30,707 | import os
import numpy as np
import paddle
import torch
import timm
from rest import build_rest as build_model
from config import get_config
from pth_rest import *
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
print(name, p... | null |
30,708 | import os
import numpy as np
import paddle
import torch
import timm
from rest import build_rest as build_model
from config import get_config
from pth_rest import *
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
print(name, par... | null |
30,709 | import os
import numpy as np
import paddle
import torch
import timm
from rest import build_rest as build_model
from config import get_config
from pth_rest import *
def torch_to_paddle_mapping(model_name, config):
mapping = []
layer_mapping = [
('stem.conv1', 'stem.conv1'),
('stem.norm1', 'stem.n... | null |
30,719 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
def translate_relative_level_to_arg(level):
# range [-0.45, 0.45]
level = (level / LEVEL_DENOM) * 0.45
level = randomly_negate(level)
return level, | null |
30,751 | from functools import partial
import paddle
import paddle.nn as nn
from droppath import DropPath
class LeViT(nn.Layer):
def __init__(self,
image_size=224,
patch_size=16,
in_channels=3,
num_classes=1000,
embed_dim=(192,),
... | Build LeViT by reading options in config object Args: config: config instance contains setting options Returns: model: nn.Layer, TopFormer model |
30,755 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,756 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,757 | import os
from yacs.config import CfgNode as CN
import yaml
def _update_config_from_file(config, cfg_file):
"""Load cfg file (.yaml) and update config object
Args:
config: config object
cfg_file: config file (.yaml)
Return:
None
"""
config.defrost()
with open(cfg_file, 'r... | Update config by ArgumentParser Configs that are often used can be updated from arguments Args: args: ArgumentParser contains options Return: config: updated config |
30,758 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
30,759 | import os
import numpy as np
import paddle
import torch
import timm
from levit import build_levit as build_model
from config import get_config
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
print(name, param.shape)
print... | null |
30,760 | import os
import numpy as np
import paddle
import torch
import timm
from levit import build_levit as build_model
from config import get_config
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
print(name, param.shape)
print('... | null |
30,761 | import os
import numpy as np
import paddle
import torch
import timm
from levit import build_levit as build_model
from config import get_config
def torch_to_paddle_mapping(model_name, config):
mapping = [
('patch_embed.0.c', 'patch_embed.0.conv'),
('patch_embed.0.bn', 'patch_embed.0.norm'),
(... | null |
30,800 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
30,801 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
30,809 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.