id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
23,440
from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy import numpy as np import tensorflow as tf from tensorflow.keras import activations from tensorflow.keras import layers from tensorflow.python.util import nest from tf_nndct.graph import OpTypes from...
null
23,441
from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy import numpy as np import tensorflow as tf from tensorflow.keras import activations from tensorflow.keras import layers from tensorflow.python.util import nest from tf_nndct.graph import OpTypes from...
null
23,442
from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy import numpy as np import tensorflow as tf from tensorflow.keras import activations from tensorflow.keras import layers from tensorflow.python.util import nest from tf_nndct.graph import OpTypes from...
null
23,443
from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy import numpy as np import tensorflow as tf from tensorflow.keras import activations from tensorflow.keras import layers from tensorflow.python.util import nest from tf_nndct.graph import OpTypes from...
null
23,444
from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy import numpy as np import tensorflow as tf from tensorflow.keras import activations from tensorflow.keras import layers from tensorflow.python.util import nest from tf_nndct.graph import OpTypes from...
null
23,445
from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy import numpy as np import tensorflow as tf from tensorflow.keras import activations from tensorflow.keras import layers from tensorflow.python.util import nest from tf_nndct.graph import OpTypes from...
null
23,446
from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy import numpy as np import tensorflow as tf from tensorflow.keras import activations from tensorflow.keras import layers from tensorflow.python.util import nest from tf_nndct.graph import OpTypes from...
null
23,447
import copy import os import shutil import tensorflow as tf from tensorflow.python.distribute import distribution_strategy_context as ds_context from tensorflow.python.framework.convert_to_constants import convert_variables_to_constants_v2 from typing import List, Tuple from nndct_shared.expanding.expander import Chann...
null
23,448
import os from typing import Optional import tensorflow as tf from nndct_shared.base import NNDCT_KEYS, NNDCT_OP, GLOBAL_MAP from nndct_shared.utils import option_util, NndctOption, NndctScreenLogger from tf_nndct.graph import OpTypes from tf_nndct.graph import builder from tf_nndct.graph import ops from tf_nndct.graph...
null
23,449
import os from typing import Optional import tensorflow as tf from nndct_shared.base import NNDCT_KEYS, NNDCT_OP, GLOBAL_MAP from nndct_shared.utils import option_util, NndctOption, NndctScreenLogger from tf_nndct.graph import OpTypes from tf_nndct.graph import builder from tf_nndct.graph import ops from tf_nndct.graph...
null
23,450
from tensorflow.python.util import tf_inspect from tf_nndct.utils import registry from tf_nndct.layers import quantization _quant_module_registry = registry.Registry('quant_op') def get_quant_module(op_type, default=None): if op_type not in _quant_module_registry: return default return _quant_module_registry.l...
null
23,451
def fix_neuron(input, fp_tensor, bit_width, method=4): #return kernels.nndct_fix_neuron_v2(input, valmax, valamp, method) return kernels.nndct_fix_neuron(input, fp_tensor, bit_width, method)
null
23,452
def diffs_fix_pos(input, bit_width=8, range=5, method=4): return kernels.nndct_diff_s(input, bit_width, range, method)
null
23,453
def stat_act_pos(fp_tensor, fp_stat_tensor): return kernels.nndct_stat_act_pos(fp_tensor, fp_stat_tensor)
null
23,454
def scaleop(input, scale): return kernels.nndct_scale_op(input, float(scale))
null
23,455
def table_lookup(input, table, fragpos, type): return kernels.nndct_table_lookup(input, table, fragpos, type)
null
23,456
def simulation(input, fragpos, type): return kernels.nndct_simulation(input, fragpos, type)
null
23,457
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
Strips off ports and other decorations to get the underlying node name.
23,458
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,459
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,460
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
Parse data from given `tensor`.
23,461
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
Convert a list of AttributeProto to a dict, with names as keys.
23,462
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,463
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,464
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,465
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,466
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,467
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,468
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,469
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,470
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,471
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,472
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,473
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,474
import os import tensorflow as tf from distutils.version import LooseVersion from google.protobuf import text_format from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import dtypes as tf_dtypes from tensorflow.python.framework import tensor_util from tf_nndct.graph import dtypes as nndct...
null
23,475
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.core.framework import attr_value_pb2 from tensorflow.core.framework import graph_pb2 from tensorflow.core.framework import tensor_shape_pb2 from tensorflow.core.framework impor...
Replaces all the variables in a graph with constants of the same values. TensorFlow 2.0 function for converting all Variable ops into Const ops holding the same values. This makes it possible to describe the network fully with a single GraphDef file, and allows the removal of a lot of ops related to loading and saving ...
23,476
from __future__ import absolute_import from __future__ import division from __future__ import print_function import logging as _logging import os as _os import sys as _sys import time as _time import traceback as _traceback from logging import DEBUG from logging import ERROR from logging import FATAL from logging impor...
null
23,477
from __future__ import absolute_import from __future__ import division from __future__ import print_function import logging as _logging import os as _os import sys as _sys import time as _time import traceback as _traceback from logging import DEBUG from logging import ERROR from logging import FATAL from logging impor...
null
23,478
from __future__ import absolute_import from __future__ import division from __future__ import print_function import logging as _logging import os as _os import sys as _sys import time as _time import traceback as _traceback from logging import DEBUG from logging import ERROR from logging import FATAL from logging impor...
null
23,482
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import shutil import tempfile from google.protobuf import text_format The provided code snippet includes necessary dependencies for implementing the `to_list` function. Write a Python function `def to...
Normalizes a list/tuple to a list. If a tensor is passed, we return a list of size 1 containing the tensor. Arguments: x: target object to be normalized. Returns: A list.
23,483
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import shutil import tempfile from google.protobuf import text_format def get_temp_directory(): return os.environ.get("VAI_TEMP_DIRECTORY", tempfile.mkdtemp())
null
23,484
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import shutil import tempfile from google.protobuf import text_format def delete_directory(path): if os.path.exists(path): shutil.rmtree(path)
null
23,485
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import shutil import tempfile from google.protobuf import text_format def write_proto(path, message, as_text=False): dir_name = os.path.dirname(path) mkdir_if_not_exist(dir_name) if dir_name: ...
null
23,486
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import shutil import tempfile from google.protobuf import text_format def is_list_or_tuple(obj): return isinstance(obj, (list, tuple))
null
23,487
import collections import tensorflow as tf from typing import Any, Callable, Dict, List, Optional, Union from tensorflow.keras import layers from tensorflow.python.eager import def_function from tensorflow.python.keras.engine import base_layer_utils from tensorflow.python.ops import array_ops from tensorflow.python.tra...
null
23,488
import collections import tensorflow as tf from typing import Any, Callable, Dict, List, Optional, Union from tensorflow.keras import layers from tensorflow.python.eager import def_function from tensorflow.python.keras.engine import base_layer_utils from tensorflow.python.ops import array_ops from tensorflow.python.tra...
null
23,489
import collections import tensorflow as tf from typing import Any, Callable, Dict, List, Optional, Union from tensorflow.keras import layers from tensorflow.python.eager import def_function from tensorflow.python.keras.engine import base_layer_utils from tensorflow.python.ops import array_ops from tensorflow.python.tra...
null
23,490
import collections import tensorflow as tf from typing import Any, Callable, Dict, List, Optional, Union from tensorflow.keras import layers from tensorflow.python.eager import def_function from tensorflow.python.keras.engine import base_layer_utils from tensorflow.python.ops import array_ops from tensorflow.python.tra...
Get inbound layers for nested Functional models. The inbound_layer of a submodel is another Functional model, this function find the output layers of that model and treats them as the actual inbound layers.
23,491
import collections import tensorflow as tf from typing import Any, Callable, Dict, List, Optional, Union from tensorflow.keras import layers from tensorflow.python.eager import def_function from tensorflow.python.keras.engine import base_layer_utils from tensorflow.python.ops import array_ops from tensorflow.python.tra...
Stat the complexity of the given model. Currently includes macs and params. MACs: multiply–accumulate operations that performs a += b x c Params: total number of parameters of a model. Args: model: A model instance. inputs_kwargs: An optional dictionary of argument pairs specifying inputs' shape specifications to getti...
23,492
from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.core.framework import graph_pb2 from tensorflow.python.platform import gfile def export_to_graphviz(graph): pass
null
23,493
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from nndct_shared.utils.tensor_util import convert_parameter_tensor_format from nndct_shared.utils.tensor_util import DataFormatMap from nndct_shared.pruning import pruning_lib from nndct_shar...
null
23,494
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from nndct_shared.utils.tensor_util import convert_parameter_tensor_format from nndct_shared.utils.tensor_util import DataFormatMap from nndct_shared.pruning import pruning_lib from nndct_shar...
null
23,495
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from nndct_shared.utils.tensor_util import convert_parameter_tensor_format from nndct_shared.utils.tensor_util import DataFormatMap from nndct_shared.pruning import pruning_lib from nndct_shar...
convert the nndct tensor format -> tf format(channal last) more in nndct_shared/utils/tensor_util.py
23,496
import argparse import numpy as np import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tf_nndct import IterativePruningRunner num_classes = 10 input_shape = (28, 28, 1) def build_model(pretrained=None): # Implementation from https://github.com/keras-team/keras-io/blob/master...
null
23,497
import argparse import numpy as np import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tf_nndct import IterativePruningRunner (x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data('mnist.npz') x_train = x_train.astype("float32") / 255 x_test = x_test.astype("flo...
null
23,498
import argparse import numpy as np import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tf_nndct import IterativePruningRunner input_shape = (28, 28, 1) def evaluate(model): model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"]) score = model....
null
23,499
import argparse import numpy as np import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tf_nndct import IterativePruningRunner input_shape = (28, 28, 1) def transform(model): input_spec = tf.TensorSpec((1, *input_shape), tf.float32) runner = IterativePruningRunner(model, in...
null
23,500
import argparse import numpy as np import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tf_nndct import IterativePruningRunner def parse_args(): parser = argparse.ArgumentParser() parser.add_argument( "-t", "--train", action="store_true", help="If tr...
null
23,501
from tf1_nndct.optimization.pruning import IterativePruningRunner import tensorflow as tf import numpy as np from nets.resnet_v2 import resnet_v2_50 def eval_fn(frozen_graph_def: tf.compat.v1.GraphDef) -> float: with tf.compat.v1.Session().as_default() as sess: return 0.5
null
23,502
from tf1_nndct.optimization.pruning import IterativePruningRunner import tensorflow as tf import numpy as np from nets.alexnet import alexnet_v2 def eval_fn(frozen_graph_def: tf.compat.v1.GraphDef) -> float: with tf.compat.v1.Session().as_default() as sess: return 0.5
null
23,503
from tf1_nndct.optimization.pruning import IterativePruningRunner import tensorflow as tf from tensorflow.keras import layers import numpy as np def mnist_convnet(): num_classes = 10 input_shape = (28, 28, 1) model = keras.Sequential([ layers.InputLayer(input_shape=input_shape), layers.Conv2D(16, kern...
null
23,504
from tf1_nndct.optimization.pruning import IterativePruningRunner import tensorflow as tf import numpy as np from nets.vgg import vgg_16 def eval_fn(frozen_graph_def: tf.compat.v1.GraphDef) -> float: with tf.compat.v1.Session().as_default() as sess: return 0.5
null
23,505
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf slim = tf.contrib.slim def alexnet_v2_arg_scope(weight_decay=0.0005): with slim.arg_scope([slim.conv2d, slim.fully_connected], activation_fn=tf.nn.relu, ...
null
23,506
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf slim = tf.contrib.slim trunc_normal = lambda stddev: tf.truncated_normal_initializer(0.0, stddev) The provided code snippet includes necessary dependencies for implementing the `alexnet_...
AlexNet version 2. Described in: http://arxiv.org/pdf/1404.5997v2.pdf Parameters from: github.com/akrizhevsky/cuda-convnet2/blob/master/layers/ layers-imagenet-1gpu.cfg Note: All the fully_connected layers have been transformed to conv2d layers. To use in classification mode, resize input to 224x224 or set global_pool=...
23,507
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from nets import inception_utils slim = tf.contrib.slim trunc_normal = lambda stddev: tf.truncated_normal_initializer(0.0, stddev) def inception_v3_base(inputs, fina...
Inception model from http://arxiv.org/abs/1512.00567. "Rethinking the Inception Architecture for Computer Vision" Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, Zbigniew Wojna. With the default arguments this method constructs the exact model defined in the paper. However, one can experiment with ...
23,508
from __future__ import absolute_import from __future__ import division from __future__ import print_function from collections import namedtuple import functools import tensorflow as tf slim = tf.contrib.slim def mobilenet_v1_base(inputs, final_endpoint='Conv2d_13_pointwise', ...
Mobilenet v1 model for classification. Args: inputs: a tensor of shape [batch_size, height, width, channels]. num_classes: number of predicted classes. If 0 or None, the logits layer is omitted and the input features to the logits layer (before dropout) are returned instead. dropout_keep_prob: the percentage of activat...
23,509
from __future__ import absolute_import from __future__ import division from __future__ import print_function from collections import namedtuple import functools import tensorflow as tf def wrapped_partial(func, *args, **kwargs): partial_func = functools.partial(func, *args, **kwargs) functools.update_wrapper(parti...
null
23,510
from __future__ import absolute_import from __future__ import division from __future__ import print_function from collections import namedtuple import functools import tensorflow as tf slim = tf.contrib.slim The provided code snippet includes necessary dependencies for implementing the `mobilenet_v1_arg_scope` functio...
Defines the default MobilenetV1 arg scope. Args: is_training: Whether or not we're training the model. If this is set to None, the parameter is not added to the batch_norm arg_scope. weight_decay: The weight decay to use for regularizing the model. stddev: The standard deviation of the trunctated normal weight initiali...
23,511
from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections import tensorflow as tf slim = tf.contrib.slim The provided code snippet includes necessary dependencies for implementing the `resnet_arg_scope` function. Write a Python function `def resnet_...
Defines the default ResNet arg scope. TODO(gpapan): The batch-normalization related default values above are appropriate for use in conjunction with the reference ResNet models released at https://github.com/KaimingHe/deep-residual-networks. When training ResNets from scratch, they might need to be tuned. Args: weight_...
23,512
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf slim = tf.contrib.slim The provided code snippet includes necessary dependencies for implementing the `inception_arg_scope` function. Write a Python function `def inception_arg_scope(wei...
Defines the default arg scope for inception models. Args: weight_decay: The weight decay to use for regularizing the model. use_batch_norm: "If `True`, batch_norm is applied after each convolution. batch_norm_decay: Decay for batch norm moving average. batch_norm_epsilon: Small float added to variance to avoid dividing...
23,513
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from nets import resnet_utils def resnet_v2(inputs, blocks, num_classes=None, is_training=True, global_pool=True, out...
ResNet-50 model of [1]. See resnet_v2() for arg and return description.
23,514
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from nets import resnet_utils def resnet_v2(inputs, blocks, num_classes=None, is_training=True, global_pool=True, out...
ResNet-101 model of [1]. See resnet_v2() for arg and return description.
23,515
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from nets import resnet_utils def resnet_v2(inputs, blocks, num_classes=None, is_training=True, global_pool=True, out...
ResNet-152 model of [1]. See resnet_v2() for arg and return description.
23,516
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from nets import resnet_utils def resnet_v2(inputs, blocks, num_classes=None, is_training=True, global_pool=True, out...
ResNet-200 model of [2]. See resnet_v2() for arg and return description.
23,517
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf slim = tf.contrib.slim The provided code snippet includes necessary dependencies for implementing the `vgg_arg_scope` function. Write a Python function `def vgg_arg_scope(weight_decay=0....
Defines the VGG arg scope. Args: weight_decay: The l2 regularization coefficient. Returns: An arg_scope.
23,518
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf slim = tf.contrib.slim The provided code snippet includes necessary dependencies for implementing the `vgg_a` function. Write a Python function `def vgg_a(inputs, num_classes=1...
Oxford Net VGG 11-Layers version A Example. Note: All the fully_connected layers have been transformed to conv2d layers. To use in classification mode, resize input to 224x224. Args: inputs: a tensor of size [batch_size, height, width, channels]. num_classes: number of predicted classes. If 0 or None, the logits layer ...
23,519
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf slim = tf.contrib.slim The provided code snippet includes necessary dependencies for implementing the `vgg_16` function. Write a Python function `def vgg_16(inputs, num_classe...
Oxford Net VGG 16-Layers version D Example. Note: All the fully_connected layers have been transformed to conv2d layers. To use in classification mode, resize input to 224x224. Args: inputs: a tensor of size [batch_size, height, width, channels]. num_classes: number of predicted classes. If 0 or None, the logits layer ...
23,520
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf slim = tf.contrib.slim The provided code snippet includes necessary dependencies for implementing the `vgg_19` function. Write a Python function `def vgg_19(inputs, num_classe...
Oxford Net VGG 19-Layers version E Example. Note: All the fully_connected layers have been transformed to conv2d layers. To use in classification mode, resize input to 224x224. Args: inputs: a tensor of size [batch_size, height, width, channels]. num_classes: number of predicted classes. If 0 or None, the logits layer ...
23,521
from tf1_nndct.optimization.pruning import IterativePruningRunner import tensorflow as tf import numpy as np from nets.inception_v3 import inception_v3 def eval_fn(frozen_graph_def: tf.compat.v1.GraphDef) -> float: with tf.compat.v1.Session().as_default() as sess: return 0.5
null
23,522
from tf1_nndct.optimization.pruning import IterativePruningRunner import tensorflow as tf import numpy as np from nets.mobilenet_v1 import mobilenet_v1 def eval_fn(frozen_graph_def: tf.compat.v1.GraphDef) -> float: with tf.compat.v1.Session().as_default() as sess: return 0.5
null
23,523
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
23,524
import argparse import os import torch import torchvision.datasets as datasets from torchvision.models.mobilenet import mobilenet_v2 import torchvision.transforms as transforms from pytorch_nndct import OFAPruner def get_gpus(device): return [int(i) for i in device.split(',')]
null
23,525
import argparse import os import torch import torchvision.datasets as datasets from torchvision.models.mobilenet import mobilenet_v2 import torchvision.transforms as transforms from pytorch_nndct import OFAPruner class AverageMeter(object): """Computes and stores the average and current value""" def __init__(self, ...
null
23,526
import argparse import os import torch import torchvision.datasets as datasets from torchvision.models.mobilenet import mobilenet_v2 import torchvision.transforms as transforms from pytorch_nndct import OFAPruner def calibration_fn(model, train_loader, number_forward=16): model.eval() for n, m in model.named_modul...
null
23,527
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 def get_gpus(device): return [int(i) for i in device.split(',')]
null
23,528
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 The provided code snippet includes necessary dependencies for implementing the `adjust_learn...
Sets the learning rate to the initial LR decayed by every 2 epochs
23,529
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
23,530
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 def train(train_loader, model, criterion, optimizer, epoch): batch_time = AverageMeter('Tim...
null
23,531
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): def __init__(self, name, fmt=':f'): def reset(self): ...
null
23,532
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 The provided code snippet includes necessary dependencies for implementing the `adjust_learning_rate` function. Write...
Sets the learning rate to the initial LR decayed by every 2 epochs
23,533
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): """Computes and stores the average and current value""" def __init__(self, name, fmt='...
null
23,534
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 def train(train_loader, model, criterion, optimizer, epoch): batch_time = AverageMeter('Time', ':6.3f') data_time ...
null
23,535
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
23,536
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 def load_weights(model, model_path): checkpoint = torch.load(model_path) model.load_state_dict(checkpoint) retu...
null
23,537
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 args, _ = parser.parse_known_args() def train(train_loader, model, criterion, optimizer, epoch): batch_time = Averag...
null
23,538
import os import shutil import subprocess import sys import setuptools.command.develop import setuptools.command.install import torch from setuptools import find_packages, setup from torch.utils.cpp_extension import BuildExtension, CppExtension from distutils import core from distutils.core import Distribution from dis...
null
23,539
import os import shutil import subprocess import sys import setuptools.command.develop import setuptools.command.install import torch from setuptools import find_packages, setup from torch.utils.cpp_extension import BuildExtension, CppExtension from distutils import core from distutils.core import Distribution from dis...
null
23,540
import os import shutil import subprocess import sys import setuptools.command.develop import setuptools.command.install import torch from setuptools import find_packages, setup from torch.utils.cpp_extension import BuildExtension, CppExtension from distutils import core from distutils.core import Distribution from dis...
null
23,541
import os import shutil import subprocess import sys import setuptools.command.develop import setuptools.command.install import torch from setuptools import find_packages, setup from torch.utils.cpp_extension import BuildExtension, CppExtension from distutils import core from distutils.core import Distribution from dis...
null
23,542
import torch import torch.nn as nn import torch.nn.functional as F import torch def get_mask(matrix, m, n): mat = reshape_tensor(matrix, m) topk, indices = mat.abs().topk(k=n, dim=1, sorted=False) mask_matrix = torch.zeros_like(mat) mask_min = torch.min(topk, dim=-1).values mask_min = mask_min.unsqueeze(-1).r...
null