repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
NerveNet
NerveNet-master/util/nn_cells.py
""" Basic cells of neural network Renjie Liao """ import tensorflow as tf from six.moves import xrange def weight_variable(shape, init_method=None, dtype=tf.float32, init_para=None, wd=None, seed=1234, ...
16,843
31.330134
80
py
NerveNet
NerveNet-master/util/summary_handler.py
# ----------------------------------------------------------------------------- # @brief: # define the how to record the summary # @author: # Tingwu Wang # ----------------------------------------------------------------------------- import init_path from util import logger import tensorflow as tf impo...
3,068
33.875
79
py
NerveNet
NerveNet-master/util/ob_normalizer.py
# ----------------------------------------------------------------------------- # @brief: # do a running mean and normalization on the observation # This is actually very important for the performances # @Updated: # Jun., 22rd, 2017, by Tingwu Wang # Aug., 8th, 2017, add the running mean by ...
2,322
29.168831
79
py
NerveNet
NerveNet-master/util/init_path.py
../tool/init_path.py
20
20
20
py
NerveNet
NerveNet-master/util/parallel_util.py
# ----------------------------------------------------------------------------- # @brief: # Define some signals used during parallel # ----------------------------------------------------------------------------- # it makes the main trpo agent push its weights into the tunnel START_SIGNAL = 1 # it ends the tr...
659
27.695652
79
py
NerveNet
NerveNet-master/util/utils.py
# ----------------------------------------------------------------------------- # @brief: # some helper functions about stats and layers # ----------------------------------------------------------------------------- import tensorflow as tf import numpy as np import scipy.signal from six.moves import xrange ...
6,273
26.884444
80
py
NerveNet
NerveNet-master/util/logger.py
# ----------------------------------------------------------------------------- # @brief: # The logger here will be called all across the project. It is inspired # by Yuxin Wu (ppwwyyxx@gmail.com) # # @author: # Tingwu Wang, 2017, Feb, 20th # -----------------------------------------------------------...
2,698
28.336957
79
py
NerveNet
NerveNet-master/util/fpdb.py
# ----------------------------------------------------------------------------- # @brief: # some helper functions about pdb. # ----------------------------------------------------------------------------- import sys import pdb class fpdb(pdb.Pdb): ''' @brief: a Pdb subclass that may b...
621
24.916667
80
py
NerveNet
NerveNet-master/util/__init__.py
0
0
0
py
NerveNet
NerveNet-master/util/model_saver.py
# ----------------------------------------------------------------------------- # @brief: it is out-dated # in this model, we save the weights by our own function # written by Tingwu Wang # ----------------------------------------------------------------------------- import init_path import numpy as np fr...
9,731
37.466403
80
py
NerveNet
NerveNet-master/graph_util/mujoco_parser.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @brief: # Some helper functions to parse the mujoco xml template files # @author: # Tingwu Wang, Jun 23rd, 2017 # @UPDATE: # 1. add the tendon support # 2. add support for HumanoidStand...
32,830
37.624706
80
py
NerveNet
NerveNet-master/graph_util/init_path.py
../tool/init_path.py
20
20
20
py
NerveNet
NerveNet-master/graph_util/gnn_util.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @brief: # Some helper functions to parse the mujoco xml template files # @author: # Tingwu Wang, Jun 23rd, 2017 # @UPDATE: # ------------------------------------------------------------------------...
5,841
33.77381
79
py
NerveNet
NerveNet-master/graph_util/structure_mapper.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @author: # Tingwu Wang, Jun 23rd, 2017 # ----------------------------------------------------------------------------- import init_path from util import logger import mujoco_parser import numpy as np _BA...
7,820
39.947644
79
py
NerveNet
NerveNet-master/graph_util/graph_data_util.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @brief: # In this function, we change the data from [batch_size, ob_dim] into # [batch_size * num_node, hidden_dim] # @author: # Tingwu Wang, Jul. 13th, 2017 # ---------------------------------...
9,681
35.813688
79
py
NerveNet
NerveNet-master/graph_util/__init__.py
0
0
0
py
NerveNet
NerveNet-master/network/gated_graph_baseline_network.py
# ----------------------------------------------------------------------------- # @brief: # For the baseline network, we only need three functions to be defined # @fit, @save_checkpoint, and @load_checkpoint # @author: # Tingwu Wang, modified from kvfran and ppo repository. # ---------------------...
2,024
33.322034
79
py
NerveNet
NerveNet-master/network/baseline_network.py
# ----------------------------------------------------------------------------- # @brief: # For the baseline network, we only need three functions to be defined # @fit, @save_checkpoint, and @load_checkpoint # @author: # Tingwu Wang, modified from kvfran and ppo repository. # ---------------------...
2,867
30.173913
79
py
NerveNet
NerveNet-master/network/policy_network.py
# ----------------------------------------------------------------------------- # @author: # Tingwu Wang # TODO: 1. modify the mlp layer setting (list) # ----------------------------------------------------------------------------- import init_path import tensorflow as tf import numpy as np from util.utils im...
6,738
36.232044
79
py
NerveNet
NerveNet-master/network/__init__.py
0
0
0
py
NerveNet
NerveNet-master/network/gated_graph_policy_network.py
# ------------------------------------------------------------------------------ # @author: # Tingwu Wang, modified from the code of Renjie Liao. # @UPDATE: # 27th, Aug: MAJOR UPDATE: change the node input totally. # NOTE: Now the input is in node order # ------------------------------------------...
27,384
39.812221
80
py
NerveNet
NerveNet-master/tool/main.py
# ----------------------------------------------------------------------------- # @brief: main fucntion # ----------------------------------------------------------------------------- import gym import init_path from agent import optimization_agent from agent import rollout_master_agent from config.config import get...
3,277
30.219048
79
py
NerveNet
NerveNet-master/tool/init_path.py
# ------------------------------------------------------------------------------ # @brief: # In this file we init the path # @author: # Written by Tingwu Wang, 2016/Sep/22 # ------------------------------------------------------------------------------ import os.path as osp import sys import datetime ...
779
18.02439
80
py
NerveNet
NerveNet-master/agent/init_path.py
../tool/init_path.py
20
20
20
py
NerveNet
NerveNet-master/agent/rollout_master_agent.py
# ----------------------------------------------------------------------------- # @brief: # modified from the code of kvfran # @modified: # Tingwu Wang # ----------------------------------------------------------------------------- import multiprocessing import init_path import os from util import log...
7,361
33.726415
80
py
NerveNet
NerveNet-master/agent/rollout_agent.py
# ----------------------------------------------------------------------------- # @brief: # the agent that do the sampling of trajectories. # @author: # modified from the code of kvfran, modified by Tingwu Wang # ----------------------------------------------------------------------------- import nump...
6,817
33.609137
80
py
NerveNet
NerveNet-master/agent/optimization_agent.py
# ------------------------------------------------------------------------------ # @brief: # The optimization agent is responsible for doing the updates. # @author: # modified from the code of kvfran, modified by Tingwu Wang # -----------------------------------------------------------------------------...
37,965
39.175661
83
py
NerveNet
NerveNet-master/agent/agent.py
# ----------------------------------------------------------------------------- # @brief: # In this function, we define the base agent. # The base agent should be responsible for building the policy network, # fetch the io placeholders / tensors, and set up the variable list # @author: # cod...
12,621
36.565476
79
py
NerveNet
NerveNet-master/agent/__init__.py
0
0
0
py
NerveNet
NerveNet-master/environments/asset_generator.py
# ----------------------------------------------------------------------------- # @brief: # generate the xml files for each different sub-tasks of one master task # @author: # Tingwu Wang, Aug. 30th, 2017 # ----------------------------------------------------------------------------- import argparse im...
1,771
31.814815
79
py
NerveNet
NerveNet-master/environments/init_path.py
../tool/init_path.py
20
20
20
py
NerveNet
NerveNet-master/environments/centipede_generator.py
# ----------------------------------------------------------------------------- # @brief: # generate the centipedes # @author: # Tingwu Wang, Sept. 1st, 2017 # ----------------------------------------------------------------------------- import numpy as np MUJOCO_XML_HEAD = ''' <mujoco model="centiped...
7,395
36.353535
163
py
NerveNet
NerveNet-master/environments/__init__.py
0
0
0
py
NerveNet
NerveNet-master/environments/reacher_generator.py
# ----------------------------------------------------------------------------- # @brief: # generate the reacher # @author: # Tingwu Wang, Sept. 3rd, 2017 # ----------------------------------------------------------------------------- MUJOCO_XML_HEAD = ''' <mujoco model="modified_reacher"> <compiler...
4,800
40.034188
156
py
NerveNet
NerveNet-master/environments/register.py
# ----------------------------------------------------------------------------- # @brief: # register the environments here # @author: # Tingwu Wang, July 3rd, 2017 # ----------------------------------------------------------------------------- from gym.envs.registration import register import num2words...
9,106
33.236842
79
py
NerveNet
NerveNet-master/environments/snake_generator.py
# ----------------------------------------------------------------------------- # @brief: # generate the snakes # @author: # Tingwu Wang, Sept. 1st, 2017 # ----------------------------------------------------------------------------- MUJOCO_XML_HEAD = ''' <mujoco model="swimmer"> <compiler angle="de...
3,940
35.155963
163
py
NerveNet
NerveNet-master/environments/transfer_env/snake_env.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @brief: # The snake environments. # @author: # Tingwu (Wilson) Wang, Aug. 30nd, 2017 # ----------------------------------------------------------------------------- import numpy as np from gym impor...
5,427
24.847619
79
py
NerveNet
NerveNet-master/environments/transfer_env/reacher_env.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @brief: # The reacher task # @author: # Tingwu (Wilson) Wang, July 22nd, 2017 # ----------------------------------------------------------------------------- import numpy as np from gym import utils...
8,703
23.449438
79
py
NerveNet
NerveNet-master/environments/transfer_env/antS.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @brief: # The slim ant environments. # @author: # Tingwu (Wilson) Wang, Aug. 30nd, 2017 # ----------------------------------------------------------------------------- import numpy as np from gym im...
2,175
34.672131
92
py
NerveNet
NerveNet-master/environments/transfer_env/centipede_env.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @brief: # The Centipede environments. # @author: # Tingwu (Wilson) Wang, Aug. 30nd, 2017 # ----------------------------------------------------------------------------- import numpy as np from gym i...
7,635
27.492537
83
py
NerveNet
NerveNet-master/environments/transfer_env/invpendulum_env.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @brief: # The snake environments. # @author: # Tingwu (Wilson) Wang, Aug. 30nd, 2017 # ----------------------------------------------------------------------------- import numpy as np from gym impor...
3,853
26.333333
79
py
NerveNet
NerveNet-master/environments/transfer_env/__init__.py
0
0
0
py
NerveNet
NerveNet-master/environments/multitask_env/walkers.py
#!/usr/bin/env python2 # ----------------------------------------------------------------------------- # @brief: # Several Walkers # @author: # Tingwu (Wilson) Wang, Nov. 22nd, 2017 # ----------------------------------------------------------------------------- import numpy as np from gym import utils ...
15,916
30.770459
96
py
NerveNet
NerveNet-master/environments/multitask_env/__init__.py
0
0
0
py
tensorflow-onnx
tensorflow-onnx-main/setup.py
# SPDX-License-Identifier: Apache-2.0 import distutils.command.build import os import subprocess from collections import namedtuple from textwrap import dedent import setuptools.command.build_py import setuptools.command.develop import setuptools.command.install from setuptools import setup, find_packages, Command ...
3,300
31.048544
119
py
tensorflow-onnx
tensorflow-onnx-main/tools/gen_doc.py
# SPDX-License-Identifier: Apache-2.0 """ tool to list tensorflow op to onnx op mapping in markdown """ import argparse import inspect import re from collections import OrderedDict from tf2onnx.handler import tf_op parser = argparse.ArgumentParser() parser.add_argument('filename', type=str, ...
2,773
35.5
90
py
tensorflow-onnx
tensorflow-onnx-main/tools/aggregate-patterns.py
# SPDX-License-Identifier: Apache-2.0 """ Tool to find common patterns in onnx graphs. """ # don't want to rename the tool # pylint: disable=invalid-name,missing-docstring,too-many-nested-blocks import argparse import collections import csv import os from onnx import ModelProto class Node(): def __init__(sel...
5,296
27.478495
111
py
tensorflow-onnx
tensorflow-onnx-main/tools/graphtool.py
# SPDX-License-Identifier: Apache-2.0 """ simple tool to convert .meta to .pb. """ import argparse import os import tensorflow as tf def get_args(): parser = argparse.ArgumentParser() parser.add_argument("infile", nargs="*", help="event files") args = parser.parse_args() return args def to_pb(sr...
869
19.232558
85
py
tensorflow-onnx
tensorflow-onnx-main/tools/save_pretrained_model.py
# SPDX-License-Identifier: Apache-2.0 """ Save pre-trained model. """ import tensorflow as tf import numpy as np # pylint: disable=redefined-outer-name,reimported,import-outside-toplevel def save_pretrained_model(sess, outputs, feeds, out_dir, model_name="pretrained"): """Save pretrained model and config""" ...
4,060
36.601852
107
py
tensorflow-onnx
tensorflow-onnx-main/tools/profile_conversion_time.py
# SPDX-License-Identifier: Apache-2.0 # coding: utf-8 """ Profiles the conversion of a Keras model. """ import sys import cProfile from pstats import SortKey, Stats import io import argparse import tensorflow as tf from tensorflow.keras.applications import MobileNet, EfficientNetB2 from tf2onnx import tfonnx try: ...
3,675
29.890756
82
py
tensorflow-onnx
tensorflow-onnx-main/tools/tfgraph.py
# SPDX-License-Identifier: Apache-2.0 """Simple tool to guess inputs and outputs of a tensorflow model.""" import argparse from collections import Counter import tensorflow as tf IGNORE_INPUT = ["Const", "ConstV2", "Variable", "VariableV2", "RestoreV2", "Restore"] IGNORE_OUTPUT = ["NoOp", "Assign", "TensorSummaryV...
2,330
27.777778
93
py
tensorflow-onnx
tensorflow-onnx-main/tools/tf_graph_tool.py
# SPDX-License-Identifier: Apache-2.0 """ Tool for common tf graph operations. """ import argparse from collections import Counter import logging import os import sys import copy from google.protobuf import text_format import tensorflow as tf from tensorflow.python.framework import graph_util from tensorflow.core.f...
12,738
35.817919
111
py
tensorflow-onnx
tensorflow-onnx-main/tools/make_regression_test_models.py
# SPDX-License-Identifier: Apache-2.0 """Make simple test model in all tensorflow formats.""" import os import numpy as np import tensorflow as tf from tensorflow.python.framework.graph_util import convert_variables_to_constants # pylint: disable=missing-docstring # Parameters learning_rate = 0.02 training_epochs...
3,280
36.284091
113
py
tensorflow-onnx
tensorflow-onnx-main/tools/gen_tflite_flatbuffer.py
# SPDX-License-Identifier: Apache-2.0 """ Generates the files in tf2onnx/tflite used for parsing tflite flatbuffer WARNING: this script will overwrite all files in tf2onnx/tflite Before running, download the flatc executable from https://github.com/google/flatbuffers/releases and add it to PATH This script only tested...
1,684
35.630435
116
py
tensorflow-onnx
tensorflow-onnx-main/tools/onnx-optimize.py
# SPDX-License-Identifier: Apache-2.0 """ A simple tool to try optimizations on onnx graphs. This makes use of the fact that tensorflow-onnx internal graph representation is onnx so all graph, rewrite, matching and utility libaries do work which makes things easy. """ # pylint: disable=invalid-name,missing-docstring...
2,247
28.973333
103
py
tensorflow-onnx
tensorflow-onnx-main/tools/onnx-experiments.py
# SPDX-License-Identifier: Apache-2.0 """ A simple tool to try optimizations on onnx graphs. This makes use of the fact that tensorflow-onnx internal graph representation is onnx so all graph, rewrite, matching and utility libaries do work which makes things easy. """ # pylint: disable=invalid-name,missing-docstring...
5,238
32.8
106
py
tensorflow-onnx
tensorflow-onnx-main/tools/dump-onnx.py
# SPDX-License-Identifier: Apache-2.0 """ Dump onnx graph. """ # don't want to rename the tool # pylint: disable=invalid-name import argparse import collections import re import onnx from onnx import ModelProto from onnx import helper, shape_inference def get_args(): parser = argparse.ArgumentParser() par...
2,600
29.244186
99
py
tensorflow-onnx
tensorflow-onnx-main/examples/end2end_tfhub.py
# SPDX-License-Identifier: Apache-2.0 """ This example retrieves a model from tensorflowhub. It is converted into ONNX. Predictions are compared to the predictions from tensorflow to check there is no discrepencies. Inferencing time is also compared between *onnxruntime*, *tensorflow* and *tensorflow.lite*. """ from o...
2,389
29.641026
68
py
tensorflow-onnx
tensorflow-onnx-main/examples/benchmark_tfmodel_ort.py
# SPDX-License-Identifier: Apache-2.0 """ The following code compares the speed of tensorflow against onnxruntime with a model downloaded from Tensorflow Hub. """ import os import sys import time import tarfile import subprocess import datetime import numpy from tqdm import tqdm import tensorflow_hub as hub import onn...
4,054
29.954198
110
py
tensorflow-onnx
tensorflow-onnx-main/examples/end2end_tfkeras.py
# SPDX-License-Identifier: Apache-2.0 """ This example builds a simple model without training. It is converted into ONNX. Predictions are compared to the predictions from tensorflow to check there is no discrepencies. Inferencing time is also compared between *onnxruntime*, *tensorflow* and *tensorflow.lite*. """ from...
2,202
29.178082
75
py
tensorflow-onnx
tensorflow-onnx-main/examples/getting_started.py
# SPDX-License-Identifier: Apache-2.0 """ This example shows how to convert tf functions and keras models using the Python API. It also demonstrates converting saved_models from the command line. """ import tensorflow as tf import tf2onnx import numpy as np import onnxruntime as ort import os ##################### t...
1,673
25.15625
94
py
tensorflow-onnx
tensorflow-onnx-main/examples/custom_op_via_python.py
# SPDX-License-Identifier: Apache-2.0 """ A simple example how to map a custom op in python. """ import tensorflow as tf import tf2onnx from onnx import helper _TENSORFLOW_DOMAIN = "ai.onnx.converters.tensorflow" def print_handler(ctx, node, name, args): # replace tf.Print() with Identity # T output = Pri...
1,299
34.135135
106
py
tensorflow-onnx
tensorflow-onnx-main/examples/call_converter_via_python.py
# SPDX-License-Identifier: Apache-2.0 """ A simple example how to call tensorflow-onnx via python. """ import tensorflow as tf import tf2onnx with tf.Session() as sess: x = tf.placeholder(tf.float32, [2, 3], name="input") x_ = tf.add(x, x) _ = tf.identity(x_, name="output") onnx_graph = tf2onnx.tfonn...
545
29.333333
112
py
tensorflow-onnx
tensorflow-onnx-main/examples/tf_custom_op/double_and_add_one_custom_op.py
# SPDX-License-Identifier: Apache-2.0 import numpy as np import tensorflow as tf import onnx import os from tf2onnx import utils from tf2onnx.handler import tf_op from tf2onnx.tf_loader import tf_placeholder DIR_PATH = os.path.realpath(os.path.dirname(__file__)) saved_model_path = os.path.join(DIR_PATH, "model.onnx...
2,074
29.514706
116
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/verbose_logging.py
# SPDX-License-Identifier: Apache-2.0 """ A wrapper of built-in logging with custom level support and utilities. """ from contextlib import contextmanager import logging as _logging from logging import * # pylint: disable=wildcard-import, unused-wildcard-import import os import types import tensorflow as tf TF2 = ...
3,463
30.490909
110
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/graph_builder.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.graph_helper - class to help building graph, such as helping to make complex node """ import numpy as np from tf2onnx import utils, logging # pylint: disable=missing-docstring logger = logging.getLogger(__name__) class GraphBuilder(object): """help to build...
11,851
41.177936
118
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tf_utils.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.tf_utils - misc utilities for tf2onnx that interface with tensorflow """ import collections from packaging.version import Version import numpy as np import tensorflow as tf from tensorflow.core.framework import types_pb2, tensor_pb2, graph_pb2 from tensorflow.pytho...
19,760
40.514706
120
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/schemas.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.schema """ import logging import copy from collections import defaultdict, OrderedDict from onnx import defs, helper, TensorProto, OperatorSetIdProto, shape_inference from . import constants from . import utils logger = logging.getLogger(__name__) class OnnxOpSch...
6,896
34.921875
116
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/constants.py
# SPDX-License-Identifier: Apache-2.0 """ common constants """ from onnx import helper TF2ONNX_PACKAGE_NAME = __name__.split('.')[0] # Built-in supported domains ONNX_DOMAIN = "" AI_ONNX_ML_DOMAIN = "ai.onnx.ml" MICROSOFT_DOMAIN = "com.microsoft" CONTRIB_OPS_DOMAIN = "ai.onnx.contrib" # Default opset version for ...
1,860
30.016667
119
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/graph_matcher.py
# SPDX-License-Identifier: Apache-2.0 # Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LIC...
9,845
35.065934
113
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/utils.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.utils - misc utilities for tf2onnx """ import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf...
18,971
30.050736
115
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/graph.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.graph - class to manage graph manipulation on top of onnx """ import collections import copy import logging import six import numpy as np from onnx import helper, numpy_helper, shape_inference, AttributeProto, TensorProto from tf2onnx import utils, __version__, git_...
73,318
39.687569
120
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tfjs_utils.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.tfjs_utils - utilities for parsing tfjs files into onnx graphs Main functions of interest are graphs_from_tfjs and read_tfjs_graph """ import json import os import base64 import gzip import struct import logging from onnx import numpy_helper, helper import numpy as...
20,879
40.428571
118
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/version.py
# SPDX-License-Identifier: Apache-2.0 version = '1.14.0' git_version = 'd071d17ca3f5c912ce4700d03c3f5254af70e5af'
116
18.5
56
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/shape_inference.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.shape_inference - shape inference function for tf2onnx """ import logging from collections import defaultdict import numpy as np from packaging.version import Version from tf2onnx import utils from tf2onnx.tf_utils import get_tf_tensor_shape, get_tf_const_value, get_...
20,779
35.202091
120
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/convert.py
# SPDX-License-Identifier: Apache-2.0 """ python -m tf2onnx.convert : api and commandline tool to convert a tensorflow model to onnx """ # pylint: disable=unused-argument,unused-import,ungrouped-imports,wrong-import-position import argparse import os import sys from packaging.version import Version os.environ['TF_...
32,900
45.274262
119
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/__init__.py
# SPDX-License-Identifier: Apache-2.0 """tf2onnx package.""" __all__ = ["utils", "graph_matcher", "graph", "graph_builder", "tfonnx", "shape_inference", "schemas", "tf_utils", "tf_loader", "convert"] import onnx from .version import git_version, version as __version__ from . import verbose_logging as logg...
468
38.083333
143
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/keras2onnx_api.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.keras2onnx_api - Ease migration from keras2onnx to tf2onnx. Use tf2onnx.keras2onnx_api.convert_keras instead of deprecated keras2onnx.convert_keras """ # pylint: disable=unused-argument,missing-docstring from onnx import mapping, defs import tensorflow as tf import t...
2,350
35.169231
109
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/flexbuffers.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.flexbuffers - Code for parsing flexbuffers """ import struct class FlexbufferParseException(Exception): pass def read_int(buffer, offset, bit_size): size = 1 << bit_size format_char = 'bhiq'[bit_size] return struct.unpack('<' + format_char, buffer...
6,260
41.591837
106
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tf_loader.py
# SPDX-License-Identifier: Apache-2.0 """Methods to load tensorflow graph from graphdef, checkpoint or saved_model.""" import logging import uuid from packaging.version import Version import tensorflow as tf import numpy as np from google.protobuf.message import DecodeError from tensorflow.core.framework import ten...
36,808
45.358942
119
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite_utils.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.tflite_utils - utilities for parsing tflite files into onnx graph """ import collections import importlib import logging import struct from onnx import helper, onnx_pb, numpy_helper from tensorflow.core.framework import types_pb2, tensor_pb2, node_def_pb2 from tenso...
23,217
45.62249
119
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tfonnx.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.tf2onnx - rewrite tensorflow graph to onnx graph """ import collections import sys import traceback import numpy as np from onnx import onnx_pb import tf2onnx import tf2onnx.onnx_opset # pylint: disable=unused-import import tf2onnx.tflite_handlers # pylint: disab...
29,314
43.484067
119
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/symbolic_executor.py
# SPDX-License-Identifier: Apache-2.0 """symbolic executor Computes a part of the graph symbolically using SymbolicTensorElements """ import numpy as np from tf2onnx import utils # pylint: disable=logging-not-lazy,unused-argument,missing-docstring class SymbolicTensorElement: """ Helps with symbolic e...
7,492
34.511848
114
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/handler.py
# SPDX-License-Identifier: Apache-2.0 """Opset registry.""" import collections import inspect from tf2onnx import constants # pylint: disable=unused-argument,missing-docstring,invalid-name class tf_op: """Class to implement the decorator to register handlers that map tf to onnx.""" # Maps domains (strin...
5,702
37.533784
119
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite_rewriters/tfl_qdq_rewriter.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.tflite_rewriters.tfl_qdq_rewriter - Remove qdq sequences to dequantize model """ from tf2onnx.graph_matcher import OpTypePattern, GraphMatcher # pylint: disable=missing-docstring def rewrite_tfl_qdq(g, ops): pattern0 = \ OpTypePattern('TFL_DEQUANTIZE', ...
2,431
40.931034
114
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite_rewriters/tfl_select_zero_rewriter.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.tflite_rewriters.tfl_select_zero_rewriter - TFLite has a pattern to remove NaN when multiplying/dividing by 0 """ from tf2onnx.graph_matcher import OpTypePattern, GraphMatcher # pylint: disable=missing-docstring,unused-argument def rewrite_tfl_select_zero(g, ops): ...
1,832
37.1875
117
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite_rewriters/tfl_scan_output_rewriter.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.tflite_rewriters.tfl_scan_output_rewriter - Identify a common slice/concat pattern in tflite subgraphs Effectively replace A = A[:i] + [B] + A[i+1:] with A[i] = B """ import numpy as np from tf2onnx.graph_matcher import OpTypePattern, GraphMatcher # pylint: disable...
6,432
39.974522
110
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite_rewriters/__init__.py
# SPDX-License-Identifier: Apache-2.0 """tf2onnx.tflite_rewriters module""" from tf2onnx.tflite_rewriters.tfl_scan_output_rewriter import rewrite_tfl_scan_outputs from tf2onnx.tflite_rewriters.tfl_qdq_rewriter import rewrite_tfl_qdq from tf2onnx.tflite_rewriters.tfl_select_zero_rewriter import rewrite_tfl_select_zero...
518
31.4375
86
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite_rewriters/tfl_rfft_rewriter.py
# SPDX-License-Identifier: Apache-2.0 """ tf2onnx.tflite_rewriters.tfl_rfft_zero_rewriter - TFLite uses RFFT2D -> Reshape sequence to do 1D RFFT """ import numpy as np from tf2onnx.graph_matcher import OpTypePattern, GraphMatcher from tf2onnx import utils # pylint: disable=missing-docstring,unused-argument def r...
2,097
35.807018
102
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/GatherOptions.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class GatherOptions(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset...
2,242
35.177419
114
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/DepthwiseConv2DOptions.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class DepthwiseConv2DOptions(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, bu...
5,180
43.282051
120
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/DivOptions.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class DivOptions(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0)...
1,890
36.078431
120
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/RandomOptions.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class RandomOptions(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset...
2,206
34.596774
114
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/SelectV2Options.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class SelectV2Options(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offs...
1,313
31.85
114
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/SpaceToBatchNDOptions.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class SpaceToBatchNDOptions(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf...
1,355
32.9
114
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/HardSwishOptions.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class HardSwishOptions(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, off...
1,320
32.025
114
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/MatrixSetDiagOptions.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class MatrixSetDiagOptions(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf,...
1,348
32.725
114
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/QuantizationDetails.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite class QuantizationDetails(object): NONE = 0 CustomQuantization = 1
206
17.818182
68
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/UniqueOptions.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class UniqueOptions(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset...
1,800
34.313725
114
py
tensorflow-onnx
tensorflow-onnx-main/tf2onnx/tflite/Conv2DOptions.py
# SPDX-License-Identifier: Apache-2.0 # automatically generated by the FlatBuffers compiler, do not modify # namespace: tflite import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class Conv2DOptions(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset...
4,442
40.915094
120
py